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

Both arguments of PipeTransport constructor must be file objects #22

Open
kalkehcoisa opened this issue Jun 5, 2020 · 1 comment
Open

Comments

@kalkehcoisa
Copy link

Hey guys! I'm using ppft 1.6.6.1 on Python 2.7.12 linux and it's causing me this problem:

2020-06-05 09:57:07,496 INFO  [pp][DummyThread-12] Running on Python 2.7.12 linux2
[2020-06-05 09:57:07 +0000] [11841] [ERROR] Error handling request /test_request
Traceback (most recent call last):
  File "/home/an_env/local/lib/python2.7/site-packages/gunicorn/workers/async.py", line 56, in handle
    self.handle_request(listener_name, req, client, addr)
...
...
...
  File "/home/an_workspace/ref-diffs/ref_diffs/helpers.py", line 26, in async_requests
    JOB_SERVER = pp.Server(ppservers=())
  File "/home/an_env/local/lib/python2.7/site-packages/ppft/_pp.py", line 358, in __init__
    self.set_ncpus(ncpus)
  File "/home/an_env/local/lib/python2.7/site-packages/ppft/_pp.py", line 522, in set_ncpus
    range(ncpus - len(self.__workers))])
  File "/home/an_env/local/lib/python2.7/site-packages/ppft/_pp.py", line 155, in __init__
    self.start()
  File "/home/an_env/local/lib/python2.7/site-packages/ppft/_pp.py", line 162, in start
    self.t = pptransport.CPipeTransport(proc.stdout, proc.stdin)
  File "/home/an_env/local/lib/python2.7/site-packages/ppft/transport.py", line 128, in __init__
    raise TypeError("Both arguments of PipeTransport constructor " \
TypeError: Both arguments of PipeTransport constructor must be file objects

Checking around, I discovered the cause. The classes used in gevent for file readers and writers aren't properly detected as file objects. Yet, they are. So the error in transport.py is a bug.
I'm using version 1.6.6.1 installed from pip and noticed that the current code solves the issue.
Is there any deployment to pip of a newer version scheduled?
If so, it's going to save a considerable amount of work on automation scripts.

Anyway, thanks a lot for the project.
It saved us big time to be able to use async in python2 ;)
PS: we are little by little migrating to py3, but it takes lots of time and $$ we don't have right now

@kalkehcoisa
Copy link
Author

Nah! Getting the most recent dev version from git didn't solve the issue.
The check using file fails as well. So, I forked and make a fix using a weak duck typing. Just checking if there is the read and write attributes.

I think the best way of solving this is creating a function to check using types in python3 or duck typing in python2. Or, we could remove that check from PipeTransport and get rid of the problem - and let an error happen in case no file interface is provided ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant