Commit 4fb9b51c authored by Kirill Smelkov's avatar Kirill Smelkov

context: Provide way to create PyContext from raw Context

sync.PyWorkGroup will need to wrap raw Context into PyContext for
spawned workers.
parent a36efe6d
...@@ -83,3 +83,7 @@ from cython cimport final ...@@ -83,3 +83,7 @@ from cython cimport final
cdef class PyContext: cdef class PyContext:
cdef Context ctx cdef Context ctx
cdef pychan _pydone # pychan wrapping ctx.done() cdef pychan _pydone # pychan wrapping ctx.done()
# PyContext.from_ctx returns PyContext wrapping pyx/nogil-level Context ctx.
@staticmethod
cdef PyContext from_ctx (Context ctx)
...@@ -49,6 +49,10 @@ cdef PyContext _newPyCtx(Context ctx): ...@@ -49,6 +49,10 @@ cdef PyContext _newPyCtx(Context ctx):
@final @final
cdef class PyContext: cdef class PyContext:
@staticmethod
cdef PyContext from_ctx(Context ctx):
return _newPyCtx(ctx)
def __cinit__(PyContext pyctx, object bywho): def __cinit__(PyContext pyctx, object bywho):
if bywho is not _frompyx: if bywho is not _frompyx:
raise AssertionError("Context must not be instantiated by user") raise AssertionError("Context must not be instantiated by user")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment