async.asyncio_engine module¶
-
class
pyrlang.async_support.asyncio_engine.
AsyncioEngine
¶ Bases:
pyrlang.async_support.base_engine.BaseEngine
Compatibility driver for Asyncio. Create it before creating Node and pass as argument 'engine' like so:
e = AsyncioEngine() node = Node(name="py@127.0.0.1", cookie="COOKIE", engine=e)
-
call_later
(t: float, fn)¶ Schedules fn to be called after sleep(t).
-
connect_with
(protocol_class: Type[pyrlang.async_support.base_protocol.BaseProtocol], host_port: tuple, protocol_args: list, protocol_kwargs: dict) -> (<class 'pyrlang.async_support.base_protocol.BaseProtocol'>, <class 'socket.socket'>)¶ Helper which creates a new connection and feeds the data stream into a protocol handler class.
Return type: tuple(protocol_class, gevent.socket)
Parameters: - protocol_class -- A handler class which has handler functions like on_connected, consume, and on_connection_lost
- protocol_kwargs -- Keyword args to pass to the handler constructor
- protocol_args -- Args to pass to the handler constructor
- host_port -- (host,port) tuple where to connect
-
destroy
()¶
-
listen_with
(protocol_class: Type[pyrlang.async_support.base_protocol.BaseProtocol], protocol_args: list, protocol_kwargs: dict)¶ Spawns a task which would listen on a random port with a given BaseProtocol handler
-
queue_new
() → pyrlang.async_support.base_engine.BaseQueue¶ Create Asyncio queue adapter
-
run_forever
()¶ Continues running event loop forever.
-
sleep
(seconds: float)¶ Sleeps given amount of seconds in a nice compatible way.
-
socket_module
()¶ Returns current socket module (modified to be compatible with the current async library). Used functions are: * socket.create_connection * socket.error (Exception class) * socket.gethostbyname
-
spawn
(loop_fn)¶ Spawns a task which will call loop_fn repeatedly while it returns False, else will stop.
-
-
class
pyrlang.async_support.asyncio_engine.
AsyncioQueue
¶ Bases:
pyrlang.async_support.base_engine.BaseQueue
-
get
()¶ Attempt to fetch one item from the queue, or return None.
-
is_empty
()¶
-
put
(v)¶
-