• Re: [Tutor] How to stop a specific thread in Python 2.7?

    From Dan Ciprus (dciprus)@21:1/5 to marc nicole via Python-list on Thu Oct 3 22:12:15 2024
    I'd be interested too :-).

    On Thu, Sep 26, 2024 at 03:34:05AM GMT, marc nicole via Python-list wrote: >Could you show a python code example of this?


    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

    --
    Dan Ciprus

    [ curl -L http://git.io/unix ]

    -----BEGIN PGP SIGNATURE-----

    iQGzBAABCgAdFiEEKcglcpuZtkHnB5Z3auFyV77zAhoFAmb/FrwACgkQauFyV77z AhqAkQwArNGNYU4urya7MQGCgfoJNnZ08RK1vE+Cfi7RC0rlwCYwYUnEvUv75rrH U8DhRVAzeccQ4XaetNnIl8aVbaCfcHOlRsv6vBiUYFU9G3DizDPzJ8toPAvhqhPw aXCFri5NrHSZ912fQLhaej0IKWaVKnXTEBmjsMR3GEKIFhzmQdRjAatsh3C55iVZ R06Vdq/cg7Piw8b7ExO249Nr6pg6UoicgTQh6X+dllXl/sgNycfmfeAkWZDruAhW c1aMJO8W0QONA+Vi9SfK/TIM2r7V6aFv+xgKdN8qK+hxBVtt/dI05hISPmByNLSV LbndSTxgzBR2t6vNHnAYP77yXXxRbWNBZvSdR1CG9xydzzYYL5TwNLBqq3YuFrL3 +7OLnqE7Pcux3+Q4fPz6MjEHS0hUrWy7WsMqlNOuw3YXhJuPx69q2rP89O/ndhGo BlNSeHnZUdMwAhjBXjVY9c5CtVZ9KFg47TYtiJUvtOim6uptwBiUeuzjeiFRTu2y
    YP358f7w
    =PVLf
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cameron Simpson@21:1/5 to dciprus@cisco.com on Fri Oct 4 09:17:19 2024
    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>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Ciprus (dciprus)@21:1/5 to Cameron Simpson on Fri Oct 11 18:32:40 2024
    Thank you for the hint !

    On Fri, Oct 04, 2024 at 09:17:19AM GMT, Cameron Simpson wrote:
    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>

    --
    Dan Ciprus

    [ curl -L http://git.io/unix ]

    -----BEGIN PGP SIGNATURE-----

    iQGzBAABCgAdFiEEKcglcpuZtkHnB5Z3auFyV77zAhoFAmcJb0QACgkQauFyV77z AhrFAgv+NSysw+vSsoQFD5Iw+sj4iyvn/tO8NKHQjVwChVy8Tp5LeGsURSZN+YcH luKJ8CnG8SLD8Nx/EZvjRR5I4P29Bif71un8Tl2T0rAvqe6PQEQNvZREwSRYa30v jUHtJNxaCoMHj14NY4zxBwDYxxJx8IzZj9TUtAUp3/94pO2dBNzRK5XhgH9dMIaL 3E5q6pp2caQLl9p1ok5IOAR2Mbd8LbAGe669tIuW1Nv5WNBcXjNNYm4NFc6+N3LG B+Nqawsvw5cJSoQotC3s/Ls0Ng27xD6ghzopgChoFvxywLe1Np6BZ5Su3YPZ5w8g zFozDrZ5gPDWI4xfmrhJVOLQGu0E48UYvtqf6/YubSLJesXLJpFIDNI2QqzMrAd8 lJvS+eFR7pIitRN8JLCgyWhl8cLYqMWV1o7dLjhhA/qVAhSWbnAJBynt2Gxe6P1G D/BcfxRk4XWEY8AhgLcant5WHspQkSPUmgiIhIkVYvfSRSfqW3wfQdZ54iEAWz3s
    cTafAp05
    =O3di
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)