David Blume commited on 2019-07-06 11:37:15
Showing 1 changed files, with 8 additions and 3 deletions.
... | ... |
@@ -10,7 +10,8 @@ process thread pings them one at a time, and prints any changes. |
10 | 10 |
|
11 | 11 |
![Single Threaded Pings](http://dlma.com/images/python_pinger/ping_single_threaded.png) |
12 | 12 |
|
13 |
-It's so simple that I'm not going to provide a sample source file, but for the others below, I will. |
|
13 |
+It's so simple that I'm not going to provide a sample source file, |
|
14 |
+but for the others below, I will. |
|
14 | 15 |
|
15 | 16 |
### Upsides |
16 | 17 |
|
... | ... |
@@ -24,10 +25,13 @@ affect detecting a problem at another host. |
24 | 25 |
## Long Lived Workers Consuming from Queue |
25 | 26 |
|
26 | 27 |
Raymond Hettinger's [PyBay 2018 Keynote](https://pybay.com/site_media/slides/raymond2017-keynote/threading.html) |
27 |
-uses the queue module to send data between threads, so I thought I'd make a version of the pinger that did the same. |
|
28 |
+uses the queue module to send data between threads, so I thought I'd make a |
|
29 |
+version of the pinger that did the same. |
|
28 | 30 |
|
29 | 31 |
![Long Lived Queue Workers](http://dlma.com/images/python_pinger/ping_long_lived_queue_workers.png) |
30 | 32 |
|
33 |
+The main thread sends an address to a queue that the worker threads wait upon. |
|
34 |
+ |
|
31 | 35 |
See the source: **[long\_lived\_worker\_queue.py](http://git.dlma.com/python_pinger.git/blob/master/long_lived_worker_queue.py)** |
32 | 36 |
|
33 | 37 |
### Upsides |
... | ... |
@@ -43,7 +47,8 @@ updating the last status.) |
43 | 47 |
|
44 | 48 |
How about we don't keep the workers around, and only spawn them when |
45 | 49 |
there's something to do? That way, we won't waste memory when there's |
46 |
-nothing going on. |
|
50 |
+nothing going on. The main thread passes the address to the workers when |
|
51 |
+they're constructed. |
|
47 | 52 |
|
48 | 53 |
![Short Lived Workers](http://dlma.com/images/python_pinger/ping_short_lived_workers.png) |
49 | 54 |
|
50 | 55 |