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
这个官方的asyncio循环调用很快线程安全。 但没有线程锁或其他东西使用,我想知道这个代码如何使线程安全?
谢谢你的帮助!