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

NameError: name 'open' is not defined #1563

Closed
revolter opened this issue Oct 17, 2019 · 4 comments
Closed

NameError: name 'open' is not defined #1563

revolter opened this issue Oct 17, 2019 · 4 comments

Comments

@revolter
Copy link
Contributor

Steps to reproduce

Expected behaviour

Tell us what should happen

Actual behaviour

I'm getting some errors related to asyncio and tornado in production. I didn't get them locally.

Configuration

Operating System:

Ubuntu 16.04.6 LTS

Version of Python, python-telegram-bot & dependencies:

python-telegram-bot 12.2.0
certifi 2019.09.11
future 0.18.0
Python 3.5.2 (default, Oct  8 2019, 13:06:37)  [GCC 5.4.0 20160609]

Logs

2019-10-17 22:19:04,457 - asyncio - ERROR - Task was destroyed but it is pending!
task: <Task pending coro=<HTTP1ServerConnection._server_request_loop() running at /home/ubuntu/.local/share/virtualenvs/FileConvertBot-QIl0H4VU/lib/python3.5/site-packages/tornado/http1connection.py:817> wait_for=<Future pending cb=[Task._wakeup()]> cb=[IOLoop.add_future.<locals>.<lambda>() at /home/ubuntu/.local/share/virtualenvs/FileConvertBot-QIl0H4VU/lib/python3.5/site-packages/tornado/ioloop.py:690]>
2019-10-17 22:19:04,458 - asyncio - ERROR - Exception in default exception handler
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1171, in call_exception_handler
    self.default_exception_handler(context)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1148, in default_exception_handler
    logger.error('\n'.join(log_lines), exc_info=exc_info)
  File "/usr/lib/python3.5/logging/__init__.py", line 1308, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python3.5/logging/__init__.py", line 1415, in _log
    self.handle(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 1425, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 1487, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 855, in handle
    self.emit(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 1047, in emit
    self.stream = self._open()
  File "/usr/lib/python3.5/logging/__init__.py", line 1037, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined
Exception ignored in: <bound method Task.__del__ of <Task pending coro=<HTTP1ServerConnection._server_request_loop() running at /home/ubuntu/.local/share/virtualenvs/FileConvertBot-QIl0H4VU/lib/python3.5/site-packages/tornado/http1connection.py:817> wait_for=<Future pending cb=[Task._wakeup()]> cb=[IOLoop.add_future.<locals>.<lambda>() at /home/ubuntu/.local/share/virtualenvs/FileConvertBot-QIl0H4VU/lib/python3.5/site-packages/tornado/ioloop.py:690]>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 92, in __del__
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1177, in call_exception_handler
  File "/usr/lib/python3.5/logging/__init__.py", line 1308, in error
  File "/usr/lib/python3.5/logging/__init__.py", line 1415, in _log
  File "/usr/lib/python3.5/logging/__init__.py", line 1425, in handle
  File "/usr/lib/python3.5/logging/__init__.py", line 1487, in callHandlers
  File "/usr/lib/python3.5/logging/__init__.py", line 855, in handle
  File "/usr/lib/python3.5/logging/__init__.py", line 1047, in emit
  File "/usr/lib/python3.5/logging/__init__.py", line 1037, in _open
NameError: name 'open' is not defined
Copy link
Member

tsnoam commented Oct 17, 2019

@revolter This seems to be a bug with python itself.
See: https://bugs.python.org/issue26789

Have you tried using a more recent python version?

Copy link
Member

tsnoam commented Oct 17, 2019

@revolter Also, when do you experience this issue?
During shutdown? Normal operation?
Are we talking just about alarming logs or it makes the entire bot process useless? If so, how?

@revolter
Copy link
Contributor Author

During shutdown. It also started happening after updating this library to the latest version. Will try with a new Python version and report back.

@tsnoam
Copy link
Member

tsnoam commented Oct 18, 2019

With V12 we've replaced the underlying implementation of the Webhook Updater from being based on Python's stdlib http.server to Tornado based (the newer versions of tornado are using asyncio under the hood).

As of your answer we understand you witness an issue with Python itself (https://bugs.python.org/issue26789 ). Also, it is not severe as it happens only during shutdown. Therfor, we'll be closing this issue now.

@tsnoam tsnoam closed this as completed Oct 18, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants