The Thread-safe new_lock Function in Python

# Async lock
def new\_lock():
    event = aio.Event()
    return event.wait(),event.set  

# Async lock thread-safe
def new\_lock\_ts():
    class Event\_Ts(aio.Event):
        def set(self):
            self.\_loop.call\_soon\_threadsafe(super().set)  

    event = Event\_Ts()
    return event.wait(),event.set

You'll only receive email when they publish something new.

More from 19411
All posts