1

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.

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.

I'm trying to use "threading" standard module for threads.

3 Answers 3

2

Python has its own threading module that comes standard, if it helps. You can create thread objects using the threading module.

threading Documentation

thread Documentation

The thread module offers low level threading and synchronization using simple Lock objects.

Again, not sure if this helps since you're using Python under a Delphi environment.

Sign up to request clarification or add additional context in comments.

Comments

0

If a process dies all it's threads die with it, so a solution might be a separate process.

See if creating a xmlrpc server might help you, that is a simple solution for interprocess communication.

Comments

0

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.

You'll probably want the new process to end (via exit() or the like) immediately after spawning the script.

1 Comment

The execution of script in host applications ends, but the process keeps going on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.