Python Forum
how this to make a asyncio thread safe? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how this to make a asyncio thread safe? (/thread-10805.html)



how this to make a asyncio thread safe? - linziyan - Jun-07-2018

this is the official call_soon_threadsafe

def call_soon_threadsafe(self, callback, *args):
    """Like call_soon(), but thread-safe."""
    self._check_closed()
    if self._debug:
        self._check_callback(callback, 'call_soon_threadsafe')
    handle = self._call_soon(callback, args)
    if handle._source_traceback:
        del handle._source_traceback[-1]
    self._write_to_self()
    return handle
but you cant get any thing that related to thread lock, how to make thread safe ? how this code works?