@@ -99,6 +99,8 @@ def __init__(self, client_manager=None, logger=False, binary=False,
9999 self .manager = client_manager
100100 self .manager_initialized = False
101101
102+ self .async_mode = self .eio .async_mode
103+
102104 def on (self , event , handler = None , namespace = None ):
103105 """Register an event handler.
104106
@@ -306,8 +308,32 @@ def handle_request(self, environ, start_response):
306308 return self .eio .handle_request (environ , start_response )
307309
308310 def start_background_task (self , target , * args , ** kwargs ):
311+ """Start a background task using the appropriate async model.
312+
313+ This is a utility function that applications can use to start a
314+ background task using the method that is compatible with the
315+ selected async mode.
316+
317+ :param target: the target function to execute.
318+ :param args: arguments to pass to the function.
319+ :param kwargs: keyword arguments to pass to the function.
320+
321+ This function returns an object compatible with the `Thread` class in
322+ the Python standard library. The `start()` method on this object is
323+ already called by this function.
324+ """
309325 self .eio .start_background_task (target , * args , ** kwargs )
310326
327+ def sleep (self , seconds = 0 ):
328+ """Sleep for the requested amount of time using the appropriate async
329+ model.
330+
331+ This is a utility function that applications can use to put a task to
332+ sleep without having to worry about using the correct call for the
333+ selected async mode.
334+ """
335+ return self .eio .sleep (seconds )
336+
311337 def _emit_internal (self , sid , event , data , namespace = None , id = None ):
312338 """Send a message to a client."""
313339 if six .PY2 and not self .binary :
0 commit comments