MrYsLab / s3-extend

Control an Arduino Uno, Circuit Playground Express, Raspberry Pi Pico, ESP-8266, ESP-32, Picoboard, Robohat MM1, or Rasberry Pi From Scratch 3
GNU Affero General Public License v3.0
28 stars 13 forks source link

Cannot start espgw/wsgw on Windows 7 64-bit #34

Closed Anton-V-K closed 2 years ago

Anton-V-K commented 2 years ago

I'm unable to start espgw or wsgw on Windows 7 SP1 64-bit with Python 3.8.6 32-bit; backplane starts fine.

E:\Users\Anton>espgw
TelemetrixAIO Version: 1.7
Copyright (c) 2018-2020 Alan Yorinks All rights reserved.

Traceback (most recent call last):
  File "c:\program files (x86)\python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files (x86)\python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files (x86)\Python38-32\Scripts\espgw.exe\__main__.py", line 7, in <module>
  File "c:\program files (x86)\python38-32\lib\site-packages\s3_extend\gateways\esp8266_gateway.py", line 392, in esp8266_gateway
    app = Esp8266Gateway(subscriber_list, **kw_options, event_loop=loop)
  File "c:\program files (x86)\python38-32\lib\site-packages\s3_extend\gateways\esp8266_gateway.py", line 73, in __init__
    super(Esp8266Gateway, self).__init__(subscriber_list=subscriber_list,
  File "c:\program files (x86)\python38-32\lib\site-packages\python_banyan\gateway_base_aio\gateway_base_aio.py", line 113, in __init__
    super(GatewayBaseAIO, self).__init__(back_plane_ip_address=back_plane_ip_address,
  File "c:\program files (x86)\python38-32\lib\site-packages\python_banyan\banyan_base_aio\banyan_base_aio.py", line 116, in __init__
    p = psutil.Process(pid)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\__init__.py", line 326, in __init__
    self._init(pid)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\__init__.py", line 354, in _init
    self.create_time()
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\__init__.py", line 710, in create_time
    self._create_time = self._proc.create_time()
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 681, in wrapper
    raise convert_oserror(err, pid=self.pid, name=self._name)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 671, in convert_oserror
    raise exc
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 679, in wrapper
    return fun(self, *args, **kwargs)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 933, in create_time
    user, system, created = cext.proc_times(self.pid)
OSError: [WinError 0] Операция успешно завершена: '(originated from OpenProcess)'
E:\Users\Anton>wsgw -i 9002
Traceback (most recent call last):
  File "c:\program files (x86)\python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files (x86)\python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Program Files (x86)\Python38-32\Scripts\wsgw.exe\__main__.py", line 7, in <module>
  File "c:\program files (x86)\python38-32\lib\site-packages\s3_extend\gateways\ws_gateway.py", line 282, in ws_gateway
    WsGateway(subscription_list, **kw_options, event_loop=loop)
  File "c:\program files (x86)\python38-32\lib\site-packages\s3_extend\gateways\ws_gateway.py", line 79, in __init__
    super(WsGateway, self).__init__(subscriber_list=subscription_list,
  File "c:\program files (x86)\python38-32\lib\site-packages\python_banyan\banyan_base_aio\banyan_base_aio.py", line 116, in __init__
    p = psutil.Process(pid)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\__init__.py", line 326, in __init__
    self._init(pid)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\__init__.py", line 354, in _init
    self.create_time()
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\__init__.py", line 710, in create_time
    self._create_time = self._proc.create_time()
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 681, in wrapper
    raise convert_oserror(err, pid=self.pid, name=self._name)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 671, in convert_oserror
    raise exc
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 679, in wrapper
    return fun(self, *args, **kwargs)
  File "c:\program files (x86)\python38-32\lib\site-packages\psutil\_pswindows.py", line 933, in create_time
    user, system, created = cext.proc_times(self.pid)
OSError: [WinError 0] Операция успешно завершена: '(originated from OpenProcess)'

The last line in both logs translates as Operation completed successfully.

Windows 7 Home Premium (Russian, 64-bit) Version: 6.1.7601 Service Pack 1 Build 7601

Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:37:30) [MSC v.1927 32 bit (Intel)] on win32
MrYsLab commented 2 years ago

Microsoft support for Windows 7 officially ended back in January 2020. Therefore Windows 7 is not supported for this project.

Anton-V-K commented 2 years ago

Too bad you aren't going to support Windows 7, which is an optimal choice for an educational box on an old piece of hardware.

Anton-V-K commented 2 years ago

Will these servers work in Windows 8.1 64-bit?

MrYsLab commented 2 years ago

I don't know since it was only tested using Win 10, but probably it will.

Anton-V-K commented 2 years ago

Based on the hint from the closed issue #27 stating that everything works in Windows 7, I decided to try it one more time. I've installed Python 3.8.10 on Windows 7 SP1 32-bit (inside VirtualBox), and to my surprise all servers (namely backplane, espgw, wsgw and monitor) were able to start. Then I tried to run s3e and it also works! I'll try same setup on the 'real' Windows 7 and with hardware connection and with Scratch.

Anton-V-K commented 2 years ago

After playing with my Windows 7 systems I'm still puzzled about this issue: it happens only on one real Windows 7 64-bit, and everything works fine on a virtual Windows 7 32/64-bit. I guess this problem is somehow related to psutil, and there is similar issue https://github.com/giampaolo/psutil/issues/1770 which disappeared after installing Windows updates. However both tested virtual Windows 7 32/64-bit have only 3 updates installed, while the real Windows has much more updates on it. Probably some Windows updates broke the behavior, and a newer update is needed (this Windows box doesn't have recieved automatic updates). And there is another similar issue https://github.com/giampaolo/psutil/issues/1937 which isn't resolved, and it happens on Windows 10. On all systems the version of psutil is the same - 5.8.0:

...>pip freeze | findstr psutil
psutil==5.8.0

There is also closed bug https://github.com/giampaolo/psutil/issues/1877 which has nice little test script to imitate the behavior, and it seems to be related to permissions violation (access denied or something like this). Here is the rewritten fragment of BanyanBaseAIO.__init__ from banyan_base_aio.py to test the behavior:

import psutil
processName='backplane'

for pid in psutil.pids():
    print(pid)
    p = psutil.Process(pid)
    try:
        p_command = p.cmdline()
    # ignore these psutil exceptions
    except (psutil.AccessDenied, psutil.PermissionError, psutil.ZombieProcess):
        continue
    try:
        if any(processName in s for s in p_command):
            print(processName, pid) # found it!
        else:
            continue
    except UnicodeDecodeError:
        continue

This script reaches pid 4 (System process) and fails on one specific Windows 7 box. In this case psutil doesn't throw the proper exception, so the script 'crashes'.

MrYsLab commented 2 years ago

Thanks for the info. Windows and python modules are sometimes challenging. Suppose the package requires some of its code to be compiled using Visual Studio. In that case, the code may not be compatible because the Windows Version and the Visual Studio version are not always compatible.

FYI - as of about a week ago, psutil is not Python 3.10 compatible on any OS. Eventually, they will update the module, and all should work.

I don't own Windows 7, 8, or 11, so it would be impossible for me to test issues on any of these Windows versions. Windows 10 will be supported for a while. None of my computers can currently support Windows 11. Hopefully, someone will figure out how one can run Windows 11 in a virtual machine without meeting all of their security requirements.

Anton-V-K commented 2 years ago

I understand your concerns. Let's wait until next version of psutil is released - most likely the bug will be fixed there (I'm referring to https://github.com/giampaolo/psutil/pull/1887 and https://github.com/giampaolo/psutil/pull/1904).