Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal hug program not working on Win10 #500

Closed
sonovice opened this issue May 9, 2017 · 10 comments
Closed

Minimal hug program not working on Win10 #500

sonovice opened this issue May 9, 2017 · 10 comments

Comments

@sonovice
Copy link

sonovice commented May 9, 2017

I am trying to execute the following program:

import hug

@hug.get('/')
def root():
    return 'hello'

This is the error, that I'm getting:

>hug -f main.py

Traceback (most recent call last):
  File "c:\users\simon\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\simon\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Simon\AppData\Local\Programs\Python\Python36\Scripts\hug.exe\__main__.py", line 9, in <module>
  File "hug\interface.py", line 454, in hug.interface.CLI.__call__ (hug\interface.c:12894)
  File "hug\interface.py", line 99, in hug.interface.Interfaces.__call__ (hug\interface.c:3672)
  File "hug\development_runner.py", line 82, in hug.development_runner.hug (hug\development_runner.c:2605)
  File "c:\users\simon\appdata\local\programs\python\python36\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "c:\users\simon\appdata\local\programs\python\python36\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "c:\users\simon\appdata\local\programs\python\python36\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "c:\users\simon\appdata\local\programs\python\python36\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "c:\users\simon\appdata\local\programs\python\python36\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle module objects

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\simon\appdata\local\programs\python\python36\lib\multiprocessing\spawn.py", line 99, in spawn_main
    new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "c:\users\simon\appdata\local\programs\python\python36\lib\multiprocessing\reduction.py", line 82, in steal_handle
    _winapi.PROCESS_DUP_HANDLE, False, source_pid)
OSError: [WinError 87] Wrong parameter

I even deleted python and reinstalled everything. Any ideas?

@timothycrosley
Copy link
Collaborator

Sorry this happened! I don't immediately understand why windows is complaining, I'll see if I can find a copy of Windows 10 to test/reproduce with

@timothycrosley
Copy link
Collaborator

If you have time could you try running the example as follows:

hug -f main.py --manual_reload

And let me know if you still see the error? I'm curious if the new auto reload capability has some issues on Windows.

Thanks!

~Timothy

@sonovice
Copy link
Author

sonovice commented May 9, 2017

Hey Timothy,
thanks for looking into it. Turning off the auto reload feature worked. Everything runs as expected. Is there anything I could try on my side to help finding the root of the problem?

@timerooney
Copy link

timerooney commented Jun 8, 2017

I am receiving the same TypeError: can't pickle module objects error when trying to run simple programs with auto-reload enabled as well. Here is the error I get when I run the same program as Simon:

>hug -f main.py
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main

    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\hug.exe\__main__.py", line 9, in <modul
e>
  File "hug\interface.py", line 454, in hug.interface.CLI.__call__ (hug\interfac
e.c:12894)
  File "hug\interface.py", line 99, in hug.interface.Interfaces.__call__ (hug\in
terface.c:3672)
  File "hug\development_runner.py", line 82, in hug.development_runner.hug (hug\
development_runner.c:2605)
  File "c:\programdata\anaconda3\lib\multiprocessing\process.py", line 105, in s
tart
    self._popen = self._Popen(self)
  File "c:\programdata\anaconda3\lib\multiprocessing\context.py", line 223, in _
Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "c:\programdata\anaconda3\lib\multiprocessing\context.py", line 322, in _
Popen
    return Popen(process_obj)
  File "c:\programdata\anaconda3\lib\multiprocessing\popen_spawn_win32.py", line
 65, in __init__
    reduction.dump(process_obj, to_child)
  File "c:\programdata\anaconda3\lib\multiprocessing\reduction.py", line 60, in
dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle module objects
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\programdata\anaconda3\lib\multiprocessing\spawn.py", line 105, in spa
wn_main
    exitcode = _main(fd)
  File "c:\programdata\anaconda3\lib\multiprocessing\spawn.py", line 115, in _ma
in
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input

Above, the bottom part of the error messages gave an EOFError. Sometimes I'll get a PermissionError instead:

>hug -f main.py
Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main

    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\hug.exe\__main__.py", line 9, in <modul
e>
  File "hug\interface.py", line 454, in hug.interface.CLI.__call__ (hug\interfac
e.c:12894)
  File "hug\interface.py", line 99, in hug.interface.Interfaces.__call__ (hug\in
terface.c:3672)
  File "hug\development_runner.py", line 82, in hug.development_runner.hug (hug\
development_runner.c:2605)
  File "c:\programdata\anaconda3\lib\multiprocessing\process.py", line 105, in s
tart
    self._popen = self._Popen(self)
  File "c:\programdata\anaconda3\lib\multiprocessing\context.py", line 223, in _
Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "c:\programdata\anaconda3\lib\multiprocessing\context.py", line 322, in _
Popen
    return Popen(process_obj)
  File "c:\programdata\anaconda3\lib\multiprocessing\popen_spawn_win32.py", line
 65, in __init__
    reduction.dump(process_obj, to_child)
  File "c:\programdata\anaconda3\lib\multiprocessing\reduction.py", line 60, in
dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle module objects

(C:\ProgramData\Anaconda3) C:\Users\trooney\Dev>Traceback (most re
cent call last):
  File "<string>", line 1, in <module>
  File "c:\programdata\anaconda3\lib\multiprocessing\spawn.py", line 99, in spaw
n_main
    new_handle = reduction.steal_handle(parent_pid, pipe_handle)
  File "c:\programdata\anaconda3\lib\multiprocessing\reduction.py", line 87, in
steal_handle
    _winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Access is denied

My problem is a little different since it happens on a Windows 7 install, but I have a Windows 10 installation that Hug runs fine on without this issue.

EDIT: My Windows 10 installation without issues is using version 2.2.0, the Windows 7 installation with issues is using version 2.3.0.
EDIT 2: I did not realize that 2.3.0 was what added the automatic reload feature. Since the multiprocessing library works differently on Windows, I would guess it would take some work to get the feature working on Windows.

@timerooney
Copy link

The documentation relevant to this issue is here: https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods.

Specifically, multiprocessing on Windows uses the spawn start method.

Spawn: The parent process starts a fresh python interpreter process. The child process will only inherit those resources necessary to run the process objects run() method. In particular, unnecessary file descriptors and handles from the parent process will not be inherited. Starting a process using this method is rather slow compared to using fork or forkserver.

I would assume that the requirement that each child process run on a new interpreter process is causing the problem.

@appcoreopc
Copy link

Wish this command line "hug -f main.py --manual_reload" was somehow documented in the "Get Started page".

@ghost
Copy link

ghost commented Jul 14, 2017

Hi Timothy,

Thanks for suggesting the command 'hug -f main.py --manual_reload', it is working fine on Windows7. But now I am getting an error "[Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions". Can you please share your thoughts on it.

By the way, I am using Windows7 and Hug version 2.3.0.

Regards,
Ankur

@cag
Copy link
Contributor

cag commented Jul 14, 2017

Your firewall may be preventing your program from binding to the socket. You can verify that by turning off your firewall and/or running the program as an administrator. However, neither are good long term solutions, and I suspect you will have to properly set the app's access permissions. I am not on a Windows box, but you might find some luck with this article: https://technet.microsoft.com/en-us/library/cc731858(v=ws.11).aspx

@aeroaks
Copy link

aeroaks commented Sep 15, 2017

Is this closed? I can verify that it is running!

@timothycrosley
Copy link
Collaborator

This is indeed fixed now, going to close the ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants