pygame-web / pygbag

python and pygame wasm for everyone ( packager + test server + simulator )
https://github.com/pygame-web
MIT License
329 stars 38 forks source link

asyncio: _ssl not found #175

Open roistoFIN opened 2 months ago

roistoFIN commented 2 months ago

I'm writing a simple game using asyncio operations.

I'm trying to open stream: self.reader, self.writer = await asyncio.open_connection(self.server_IP, self.server_port)

It works fine in my local python environment. When I use it with pygbag, it does not.

The error in log: --8<-- 78: Async I/O error : file not found https://pypi.org/simple/_ssl/ <class 'aio.sentinel'> ∅ Traceback (most recent call last): File "/data/data/org.python/assets/site-packages/aio/toplevel.py", line 200, in interact_step self.rv = await self.shell.coro.pop(0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/org.python/assets/site-packages/aio/toplevel.py", line 109, in import_now vars(import("main"))[want] = import(want) ^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named '_ssl'

Traceback (most recent call last): File "/data/data/org.python/assets/site-packages/aio/init.py", line 293, in step loop._run_once() File "/usr/lib/python3.12/asyncio/base_events.py", line 1947, in _run_once event_list = self.selector.select(timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/selectors.py", line 323, in select r, w, = self._select(self._readers, self._writers, [], timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [Errno 8] Bad file descriptor --8<--

Am I doing something wrong or doesn't pygbag support asyncio network operations?

pmp-p commented 2 months ago

pygbag supports only a subset of BSD sockets via the normal stdlib python socket That means

poc https://pygame-web.github.io/showroom/pythongit.html?-i#src/test_socket_irc.py code

minimal irc lobby https://github.com/pygame-web/pygbag.net

if you want to build a game upon lobby code (it is free) you should join pygame community discord to get a debug channel id for your game.