question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Fix] sys.stderr.fileno() throws an AttributeError exception

See original GitHub issue

When I tried to delivered the playwright tasks via celery==4.4.7, I got an AttributeError exception at line 50 in main.py.

except AttributeError:

I’ve checked the source from pytest, the original code is:

    except (AttributeError, io.UnsupportedOperation):
           # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
           # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
           # This is potentially dangerous, but the best we can do.
           return sys.__stderr__.fileno()

It perfectly works if I changed it to the original code, so I think we should be consistent with the original source code to enhance compatibility.

I also checked the celery official docs. The reason why I got an AttributeError exception probably is that the log proxy of celery is not support the stderr attribute.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mxschmittcommented, Oct 23, 2020
0reactions
yswtruecommented, Dec 25, 2020

it seems not to work in 0.171.0 and celery 4.47

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling sys.stderr.fileno(), after checking it is a python callable ...
Calling sys.stderr.fileno(), after checking it is a python callable(), raises an AttributeError? · According to python docs (docs.python.org/2/ ...
Read more >
Issue 5492: Error on leaving IDLE with quit() or exit() under ...
fileno(), which raises the above. This is from #9290. Bottom line: I believe quit() and exit() are broken in the current 2.7, 3.2,...
Read more >
mod_wsgi Documentation - Read the Docs
The mod_wsgi package implements a simple to use Apache module which can host any Python web application which supports the Python ...
Read more >
python-pytest-3.3.2-bp150.2.4 - SUSE Package Hub -
(#2644) - Fix error on Windows and Python 3.6+ when sys.stdout has been replaced with a stream-like object which does not implement the...
Read more >
Release notes for Python 3.5.4
bpo-30301: Fix AttributeError when using SimpleQueue.empty() under *spawn* and ... bpo-25182: The stdprinter (used as sys.stderr before the io module is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found