Hi,

I have a weird bug that seems to be triggered when using the multiprocessing
module, if web2py is launched from another directory.

I've tried to isolate the issue.  To reproduce the issue, take a clean
web2py source tarball, and make the following changes:

1. to the end of *applications/welcome/controllers/default.py* add the
lines:
import alpha
def bravo():
    return alpha.charlie()

2. create a new file *applications\welcome\modules\alpha.py* with the
following content
from multiprocessing import Process, Manager

def delta(output):
    output.append('Hello, world!')

def charlie():
    output = Manager().list()
    p = Process(target=delta, args=(output,))
    p.start()
    p.join()
    return output[0]

3. run it normally,
        d:\code\temp\web2py>python web2py.py
    ... hit *http://127.0.0.1:8000/welcome/default/bravo
<http://127.0.0.1:8000/welcome/default/bravo>* ... everything works

4. change the current working directory, and relaunch
d:\code\temp\web2py>cd ..
d:\code\temp>python web2py\web2py.py
   and you get an error.  An unhelpful ticket, but the console has the
following traceback:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\Python27\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
  File "D:\Python27\lib\multiprocessing\forking.py", line 489, in prepare
    file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named web2py


If it helps, I put a print statement before File "
*D:\Python27\lib\multiprocessing\forking.py*", line 489, and it printed out:
        ['d:\\code\\temp\\web2py\\web2py']

Something is causing the path to add the directory web2py twice!

If I run the code from one directory above that:
d:\code\temp>cd ..
d:\code>python temp\web2py\web2py.py
then the following is printed:
        ['d:\\code\\temp\\web2py\\temp\\web2py']

Again the path is repeated twice.

Can anyone help me understand what is causing this issue?  What is a
potential fix?

If it helps, the real bug got triggered when running web2py behind Apache
on Windows (modwsgi), since the wsgi script was launched from some random
Apache directory.

Regards,
Roshan Mathews

-- 
http://about.me/rosh

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to