sdizazzo / pyaltitude

Python wrapper for interacting with and making mods for the Altitude game's built in server
http://altitudegame.com/
MIT License
1 stars 0 forks source link

OSError: [Errno 12] Cannot allocate memory #8

Closed sdizazzo closed 4 years ago

sdizazzo commented 4 years ago

  File "./pyaltitude.py", line 264, in callback
    fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "./pyaltitude.py", line 237, in execute
    method(event, INIT)
  File "./pyaltitude.py", line 88, in serverHitch
    server.serverMessage("ServerHitch: %.2f" % event['duration'])
  File "/home/sean/pyaltitude/pyaltitude/commands.py", line 29, in serverMessage
    self._send('serverMessage', message)
  File "/home/sean/pyaltitude/pyaltitude/commands.py", line 20, in _send
    subprocess.run(cmd, shell=True)#,stdout=asyncio.subprocess.PIPE,stderr=asyncio.subprocess.PIPE)
  File "/usr/local/lib/python3.7/subprocess.py", line 472, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.7/subprocess.py", line 1453, in _execute_child
    restore_signals, start_new_session, preexec_fn)
OSError: [Errno 12] Cannot allocate memory```
sdizazzo commented 4 years ago

https://stackoverflow.com/questions/1367373/python-subprocess-popen-oserror-errno-12-cannot-allocate-memory/13329386#13329386

sdizazzo commented 4 years ago

I have tracked down the memory leak to this loop: https://github.com/sdizazzo/pyaltitude/blob/09460875bd7cd45b472315876108048cf54b9191/pyaltitude.py#L127 which makes sense because thats where all the magic happens. I tried cleaning up the worker in the done callback among other things, but something more elaborate is needed or I missed something. At least for now I can slow it down by upping the timeout from 0.01 to 0.1

sdizazzo commented 4 years ago

Resolved with https://github.com/sdizazzo/pyaltitude/commit/48c2cdc4a6cc466e5df491a534c458d9de2efb9d The queue was passed into the workers from when I was originally going to handle them as threads myself. So it never ended up blocking the main while loop so it was running out of control. Easy enough once I found it.