progval / Limnoria

A robust, full-featured, and user/programmer-friendly Python IRC bot, with many existing plugins.
https://docs.limnoria.net/
Other
618 stars 172 forks source link

command.process() fails if the terminal is missing #1264

Open jlu5 opened 8 years ago

jlu5 commented 8 years ago

Reported by AlexPortable in #limnoria:

ERROR 2016-09-11T18:24:13 supybot Uncaught exception in _callRegexp:
Traceback (most recent call last):
  File "/home/alexportable/.local/lib/python3.5/site-packages/supybot/callbacks.py", line 1478, in _callRegexp
    method(irc, msg, m)
  File "/home/alexportable/limnoria/plugins/SedRegex/plugin.py", line 148, in replacer
    fcn_name='replacer'):
  File "/home/alexportable/.local/lib/python3.5/site-packages/supybot/commands.py", line 149, in regexp_wrapper
    v = process(re_bool, s, reobj, timeout=timeout, pn=plugin_name, cn=fcn_name)
  File "/home/alexportable/.local/lib/python3.5/site-packages/supybot/commands.py", line 119, in process
    p.start()
  File "/home/alexportable/.local/lib/python3.5/multiprocessing/process.py", line 105, in start
    self._popen = self._Popen(self)
  File "/home/alexportable/.local/lib/python3.5/multiprocessing/context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/home/alexportable/.local/lib/python3.5/multiprocessing/context.py", line 267, in _Popen
    return Popen(process_obj)
  File "/home/alexportable/.local/lib/python3.5/multiprocessing/popen_fork.py", line 17, in __init__
    sys.stdout.flush()
OSError: [Errno 5] Input/output error
ERROR 2016-09-11T18:24:13 supybot Exception id: 0x28bfa

Relevant conversation:

09:28 <tacocat> AlexPortable: is supybot running daemonized, in the foreground, or sent to the background?
09:29 <AlexPortable> foregroudn
09:29 <AlexPortable> but my terminal closed due to inactivity
09:29 <AlexPortable> other plugins work fine
09:30 <tacocat> can you restart your bot with 'supybot -d' so that it forks to the background
09:30 <tacocat> doing a bit of research and sys.stdXXX.flush() failing may be because the terminal is dead
09:30 <AlexPortable> i start it with crontab
09:31 <tacocat> use supybot -d there
09:31 <tacocat> i'm not sure crontab even exposes a terminal for the bot to attach to
09:32 <AlexPortable> so shutdown the bot and try again?
09:32 <tacocat> yes but don't do anything to make it lose terminal
09:32 <AlexPortable> supybot -d bot.conf ?
09:32 <tacocat> if you daemonize it there is no terminal
09:32 <tacocat> yup
09:33 <AlexPortable> done
09:34 <AlexPortable> hm m the other plugins work too :D
09:34 <AlexPortable> thanks :D
progval commented 8 years ago

hmm... isn't it a bug in CPython?

progval commented 8 years ago

Submitted to Python's bugtracker. https://bugs.python.org/issue28326

progval commented 6 years ago

This issue will be fixed on Python 3.6.4: https://github.com/python/cpython/pull/4075

jlu5 commented 6 years ago

3.6.4 has been released, so I think this can be closed now.

Not quite, https://github.com/python/cpython/pull/4075#issuecomment-392238187

sunbarve commented 6 years ago

Is this issue solve for python3.5?

File "/home/alexportable/.local/lib/python3.5/multiprocessing/popen_fork.py", line 17, in init sys.stdout.flush() OSError: [Errno 5] Input/output error

progval commented 6 years ago

No, you need at least Python 3.6.4.

sunbarve commented 6 years ago

@ProgVal i have upgraded python to 3.6.4, but still get this error. File "/usr/local/lib/python3.6/multiprocessing/popen_fork.py", line 18, in init sys.stdout.flush() OSError: [Errno 5] Input/output error

progval commented 6 years ago

What does python3 -V show?

sunbarve commented 6 years ago

@ProgVal 1.if i just use python3 -V then it shown Python 3.5.2 2.if use python3.6 -V then it shows Python 3.6.4

jothiljose commented 6 years ago

I am also facing this same while hosting in AWS, Just remove the code sys.stdout.flush() from source file , now its working perfectly. let me know, Is this make any issue in future?

progval commented 6 years ago

@jothiljose You should use this patch: https://github.com/python/cpython/pull/4075/files but replace except (AttributeError, ValueError): with except (AttributeError, ValueError, OSError):

traumschule commented 5 years ago

Hi! I see the same issue with current limnoria after the parent tmux had died.

The current (running) version of this Limnoria is 2018.09.09, running on Python 3.6.5 (default, Jul 30 2018, 14:52:52) [GCC 7.3.0]. The newest versions available online are 2018.09.09 (in master), 2018.10.14 (in testing)

Will try the linked patch.