0

Using web2py (Version 2.8.2-stable+timestamp.2013.11.28.13.54.07), on 64-bit Windows, I have the following problem

There is an exe program that is started on user request (first an txt file is created then p is triggered).

 p = subprocess.Popen(['woshi_engine.exe', scriptId], shell=True, stdout = subprocess.PIPE, cwd=path_1)

while the exe file is running it is creating a txt file.

The program is stopped on user request by deleting the file the program needs as input.

when exe is started i have other requests user can trigger. it is common that request comes to server (I used microsoft network monitor to check that), but the function is not triggered. I tried using scheduler but no success. Same problem

I am really stuck here with this problem

Thank you for your help

Yebach
  • 1,661
  • 8
  • 31
  • 58

1 Answers1

0

With a help of web2py google group the solution is.

I used scheduler. Created a scheduler.py file with the following code

def runWoshiEngine(scriptId, path):

    import os, sys
    import time
    import subprocess
    p = subprocess.Popen(['woshi_engine.exe', scriptId], shell=True, stdout = subprocess.PIPE, cwd=path)
return dict(status = 1)


 from gluon.scheduler import Scheduler
 scheduler = Scheduler(db)

In my controller function

task = scheduler.queue_task(runWoshiEngine, [scriptId, path])

you also have to import scheduler (from gluon.scheduler import Scheduler)

then I run the scheduler from command prompt with the following (so if I understood correctly you have two instances of web2py running, one for webserver, one for scheduler)

web2py.py -K woshiweb -D 0 (-D 0 is for verbose logging so it can be removed)
Yebach
  • 1,661
  • 8
  • 31
  • 58