question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proper way to clear event queue

See original GitHub issue

Is there a proper way to flush the event queue? I have an application where I would like to “unhook” from the events while the callback is firing and then begin processing events again afterward. I tried using keyboard.unhook(callback) before the function and then rehooking again after the function call but it seems to maintain the event queue when unhooked.

I also tried this hacky trick but it seems to (unsurprisingly) break the processing of future events.

def unhooked_event(func):
    def wrapper(self, *args):
        #keyboard.unhook(self.event_hook)
        func(self, *args)
        #keyboard.hook(self.event_hook)
        while not keyboard._listener.queue.empty():
            e = keyboard._listener.queue.get()

Is there some functionality available to make what I want possible?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bopprehcommented, Oct 16, 2017

I think this issue is fairly specific to your problem, so I’m closing this issue. If you can think of a way to add functionality to keyboard that would be useful to other people, please don’t hesitate to reopen the issue.

0reactions
AlexEshoocommented, Oct 15, 2017

Yes it does fix the problem, thanks. I’ll have to see if I can tidy up the decorator now to be able to set and unset the flag on that thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clean up the EventQueue and PublishQueue tables
Clean up the event queue on demand · On the Sitecore Launchpad, click Control Panel, Administration tools, and Event Queue Statistics. · In...
Read more >
java swing clear the event queue - Stack Overflow
Run the SSCCE · Click on the button "Wait 3 seconds". It simulates an expensive operation. · While the cursor is busy, click...
Read more >
How to flush the event queue? - Forums - IBM Support
I have an active class that consumes events in a state-chart. In some special occasions I want to flush the event queue immediately...
Read more >
How to clear forwarding queue - OBM - Support
The last option is to delete the events from the forwarding queue directly from the database: Stop OBM services.
Read more >
Solved: clear event structure queue - NI Community
What I would like to do is to be able to clear the user event queue so if someone push a certain button...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found