Hi,
I'm pretty new to web2py and web application frameworks. I'm trying to
create a new background process in controller to handle incoming ajax
data from a user. I'm using the module multiprocessing for this.
However, when I start the new process, a new instance of web2py server
is started? I'm assuming this has something to do with forking (which
I don't know much about). Is there an easy workaround? Or should I
preferrably do this some other way, for instance with threads?
Code is as follows (controller calls function 'someinit' in a module
in module-folder):
def tekstpr(mstring,conn):
print mstring
conn.send("hello")
def someinit(userid):
from multiprocessing import Pipe, Process
parent_conn, child_conn = Pipe()
p = Process(target=tekstpr,args=("I'm alive!",child_conn))
session.procpipe = parent_conn
p.start()
session.procpipe.poll(300)
return session.procpipe.recv()