Jump to content

hschmid67

Members
  • Content Count

    6
  • Joined

  • Last visited

Everything posted by hschmid67

  1. hschmid67

    Running Python scripts in threads

    Hello, I have a REST web server written in XData (TMS) and would like to execute a Python script in a service request (ActiveDirectory - using pyad). This would be in a thread - and I cannot be sure that there would not be a parallel request that executes Python in a different thread... So it seems to me that the only way to prevent problems with parallel python calls would be to use an object pool for python requests with just one element in the pool. The other request has to wait for the first to finish... Regards Harald
  2. hschmid67

    Running Python scripts in threads

    Hello, I'm looking for something similar - implementing python scripts in webservice procedures. Were You able to find a solution for this and would You mind to share it? Regards Harald
  3. Hello, If I understand everthing right (in the official book about OTL) then one needs no monitor if a task is scheduled (instead of run) - the monitor schould be implicit. I have a very simple example that runs not as expected (using OTL 3.07.6 Tokyo): This code works (with and without the line ".MonitorWith(OmniEventMonitor1)" for i := 1 to 3 do begin CreateTask( procedure(const mTask: IOmniTask) begin CodeSite.Send('curmsg'); end, 'hallo') .MonitorWith(OmniEventMonitor1) .Run; end; But this code does not. It works only with the line ".MonitorWith(OmniEventMonitor1)". Without nothing happens (no codesite messages). for i := 1 to 3 do begin CreateTask( procedure(const mTask: IOmniTask) begin CodeSite.Send('curmsg'); end, 'hallo') .MonitorWith(OmniEventMonitor1) .Schedule; end; Did I miss something? After the second example I get a memory leak after closing my app (without the monitorwith). Regards Harald
  4. using OmniThreadLibrary I'd like to watch a task2 using another task1 to detect, if task2 is stopped or otherwise finished. The aim is to restart task2 if it stopped for any reason. Until now I use the following construct: Task1 := CreateTask( procedure(const mTask: IOmniTask) begin while not mTask.Terminated do begin Sleep(1000); // create Task2 and run it, if it is not running if Task2 = nil then begin Task2 := CreateTask( procedure(const mTask: IOmniTask) begin while not mTask.Terminated do begin Sleep(1000); end; end) .OnTerminated(procedure(const mTask: IOmniTaskControl) begin Task2 := nil; end); Task2.Run; end; end; end) .OnTerminated( procedure(const mTask: IOmniTaskControl) begin Task1 := nil; end); Task1.Run; If I try to terminate the inner task2 with this code Task2.Terminate(10000); I get the following error: The same code work well with task1: Task1.Terminate(10000); Two questions: I do not understand, what goes wrong with this code and what the "monitoring"-error means. How can I get task1 to start task2 properly, and restart it, if task2 finished? Thanks in advance
  5. hschmid67

    Watch one task with another - restart if stopped

    btw, if I call Task2.stop(); Task2.WaitFor(10000); Task2 := nil; instead of Task2.Terminate(10000); everything works - without errormessage, but the OnTerminated-Handler is not called any more (that's why I assign nil to Task2 there)...
  6. hschmid67

    Watch one task with another - restart if stopped

    Thanks for looking into my code. Attached is a selfcontained example. Terminating Task1 first and then terminating Task2 I get this error of pic1.png. Terminating Task2 first I get immediately the error of pic2.png. Test2Tasks.zip
×