code: def pop_events(self):
      '''
      Pop all events and return a `collections.deque` object. The
      returned container can be empty. This method is preferred over
      `pop_event()` as it is much faster as the lock has to be acquired
      only once and also avoids running into an infinite loop during
      event processing.
      '''
  
      with self.lock:
        events = self.events
        self.events = collections.deque()
        return eventf pop_events(self):
      '''
      Pop all events and return a `collections.deque` object. The
      returned container can be empty. This method is preferred over
      `pop_event()` as it is much faster as the lock has to be acquired
      only once and also avoids running into an infinite loop during
      event processing.
      '''
  
      with self.lock:
        events = self.events
        self.events = collections.deque()
        return events
docs: Pop all events and return a `collections.deque` object. The
      returned container can be empty. This method is preferred over
      `pop_event()` as it is much faster as the lock has to be acquired
      only once and also avoids running into an infinite loop during
      event processing.