Skip to content

Why would blocking=False be slower? #306

Answered by spyoungtech
trajano asked this question in Q&A
Discussion options

You must be logged in to vote

When you use blocking=False, a new AutoHotkey subprocess is spawned to facilitate this. It takes some time for Windows to start the process as well as for the AutoHotkey interpreter to start and run the script. In tight loops, this can account for a significant slowdown.

In fact, before the daemon mode was implemented in #111 (and later became the default in version 1.x), all function calls invoked a new AutoHotkey process! In PR #111 I also noted the significant performance difference in these operating models:

normal_ahk()  # created a new process for every command
# 50 commands completed in 5.151455640792847
asyncio.run(daemon_mode()) # runs all commands in the same process
# 50 comma…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by trajano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants