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 handlebut you cant get any thing that related to thread lock, how to make thread safe ? how this code works?