On Thu, 26 Sept 2024, 03:08 Cameron Simpson, <[email protected]> wrote:
On 25Sep2024 22:56, marc nicole <[email protected]> wrote:--
How to create a per-thread event in Python 2.7?
Every time you make a Thread, make an Event. Pass it to the thread
worker function and keep it to hand for your use outside the thread.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
https://mail.python.org/mailman/listinfo/python-list
I'd be interested too :-).
On 03Oct2024 22:12, Dan Ciprus (dciprus) <[email protected]> wrote:
I'd be interested too :-).
Untested sketch:
def make_thread(target, *a, E=None, **kw):
'''
Make a new Event E and Thread T, pass `[E,*a]` as the target
positional arguments.
A shared preexisting Event may be supplied.
Return a 2-tuple of `(T,E)`.
'''
if E is None:
E = Event()
T = Thread(target=target, args=[E, *a], kwargs=kw)
return T, E
Something along those lines.
Cheers,
Cameron Simpson <[email protected]>
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 47:09:05 |
| Calls: | 12,112 |
| Calls today: | 3 |
| Files: | 15,010 |
| Messages: | 6,518,498 |