Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 42 |
Nodes: | 6 (0 / 6) |
Uptime: | 01:01:27 |
Calls: | 220 |
Calls today: | 1 |
Files: | 824 |
Messages: | 121,521 |
Posted today: | 6 |
On Thu, 26 Sept 2024, 03:08 Cameron Simpson, <cs@cskk.id.au> wrote:
On 25Sep2024 22:56, marc nicole <mk1853387@gmail.com> 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 - Tutor@python.org
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) <dciprus@cisco.com> 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 <cs@cskk.id.au>