<p>I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script.</p>

<p>Is it possible to create threads which keep running even if the script execution  ends (but not the host process, which keeps going on). I've noticed that the program gets stuck if the executing script ends and there is thread running. However if I'll wait until the thread is finished everything goes fine.</p>

<p>I'm trying to use "threading" standard module for threads.</p>

[{'answer_id': 63767, 'author': 'pjz', 'author_id': 8002, 'author_profile': 'https://Stackoverflow.com/users/8002', 'pm_score': 0, 'selected': False, 'text': "<p>Threads by definition are part of the same process.  If you want them to keep running, they need to be forked off into a new process; see os.fork() and friends.</p>\n\n<p>You'll probably want the new process to end (via exit() or the like) immediately after spawning the script.</p>\n"}, {'answer_id': 63794, 'author': 'Toni Ruža', 'author_id': 6267, 'author_profile': 'https://Stackoverflow.com/users/6267', 'pm_score': 0, 'selected': False, 'text': "<p>If a process dies all it's threads die with it, so a solution might be a separate process.</p>\n\n<p>See if creating a xmlrpc server might help you, that is a simple solution for interprocess communication.</p>\n"}, {'answer_id': 65757, 'author': 'junkforce', 'author_id': 2153, 'author_profile': 'https://Stackoverflow.com/users/2153', 'pm_score': 2, 'selected': False, 'text': '<p>Python has its own threading module that comes standard, if it helps. You can create thread objects using the threading module.</p>\n\n<p><a href="https://docs.python.org/2/library/threading.html" rel="nofollow noreferrer">threading Documentation</a></p>\n\n<p><a href="https://docs.python.org/3/library/threading.html" rel="nofollow noreferrer">thread Documentation</a></p>\n\n<p>The thread module offers low level threading and synchronization using simple Lock objects.</p>\n\n<p>Again, not sure if this helps since you\'re using Python under a Delphi environment.</p>\n'}]
['https://Stackoverflow.com/questions/63681', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7735/']