@@ -10,25 +10,24 @@ This document covers some of AutoHotkey.py's more advanced features.
10
10
Threading
11
11
---------
12
12
13
- In Python, the :mod: `threading ` module can improve the responsiveness
14
- of applications that accept user input while other tasks are running in the
13
+ In Python, the :mod: `threading ` module can improve the responsiveness of
14
+ applications that accept user input while other tasks are running in the
15
15
background. A related use case is running I/O in parallel with computations in
16
16
another thread. These are actual OS threads, as opposed to AHK `pseudo-threads
17
17
<https://www.autohotkey.com/docs/misc/Threads.htm> `_.
18
18
19
19
AutoHotkey.py calls AHK functions from python by registering a callback in AHK
20
20
with `RegisterCallback
21
21
<https://www.autohotkey.com/docs/commands/RegisterCallback.htm> `_. *These
22
- callbacks are not thread-safe. * That is, while the *main thread * is busy executing
23
- an AHK function, calling another AHK
24
- function from *another thread * yields unpredictable results. It may even crash
25
- the program.
22
+ callbacks are not thread-safe. * That is, while the *main thread * is busy
23
+ executing an AHK function, calling another AHK function from *another thread *
24
+ yields unpredictable results. It may even crash the program.
26
25
27
26
Thus, the *global AutoHotkey lock * (GAL) was introduced. GAL ensures that only
28
27
one OS thread interacts with AHK at a time.
29
28
30
- For background threads to work, the main thread must also be crunching
31
- Python code, for example, actively waiting for the background threads to finish.
29
+ For background threads to work, the main thread must also be crunching Python
30
+ code, for example, actively waiting for the background threads to finish.
32
31
However, calling :meth: `threading.Thread.join ` in the main thread blocks AHK
33
32
message queue handling. In such cases, AHK cannot handle hotkeys and other
34
33
callbacks.
@@ -47,8 +46,8 @@ asyncio
47
46
-------
48
47
49
48
AutoHotkey.py works well with :mod: `asyncio `. When starting a long-running loop,
50
- schedule the :func: `ahkpy.sleep ` call repeatedly. This gives AHK time to
51
- process its message queue::
49
+ schedule the :func: `ahkpy.sleep ` call repeatedly. This gives AHK time to process
50
+ its message queue::
52
51
53
52
import asyncio
54
53
0 commit comments