Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Not able to start an instantiated Thread in a child process through multiprocessing.Process in python 3.13 #134381

Open
Labels
3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error
@anadrianmanrique

Description

@anadrianmanrique

Bug report

Bug description:

I'm experiencing an issue specifically in python 3.13 regarding Threads in the context of multiprocessing.
The following code is working in python < 3.13

frommultiprocessingimportProcessfromthreadingimportThreadimporttimeclassMyThread(Thread):def__init__(self):Thread.__init__(self)self.__data=''defrun(self):print("Hi from thread")print(self.__data)classAclass():def__init__(self):self._t=MyThread()self._t.daemon=Truedefstart(self):self._t.start()print("thread started")if__name__=='__main__':t=Aclass()p=Process(target=t.start )p.start()time.sleep(2)

After executing the above in python 3.13 I get this output:

 File "/usr/lib/python3.13/multiprocessing/process.py", line 313, in _bootstrap    self.run()    ~~~~~~~~^^  File "/usr/lib/python3.13/multiprocessing/process.py", line 108, in run    self._target(*self._args, **self._kwargs)    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/kali/impacket/master/impacket/tests/SMB_RPC/test_bug_process_thread.py", line 18, in start    self._t.start()    ~~~~~~~~~~~~~^^  File "/usr/lib/python3.13/threading.py", line 973, in start    _start_joinable_thread(self._bootstrap, handle=self._handle,    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                           daemon=self.daemon)                           ^^^^^^^^^^^^^^^^^^^RuntimeError: thread already started

I managed to workaround this by delaying the Thread instance initialization, moving the Thread.init() call to start() method in the derived class, so everything gets executed in the context of the child process.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp