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 #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pp/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class PipeTransport(Transport):
def __init__(self, r, w):
self.scache = {}
self.exiting = False
if isinstance(r, types.FileType) and isinstance(w, types.FileType):
if hasattr(r, 'read') and hasattr(w, 'write'):
self.r = r
self.w = w
else:
Expand Down
6 changes: 3 additions & 3 deletions ppft/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, r, w):
#open('/tmp/pp.debug', 'a+').write(repr((r,w))+'\n')
self.scache = {}
self.exiting = False
if isinstance(r, ppc.file) and isinstance(w, ppc.file):
if hasattr(r, 'read') and hasattr(w, 'write'):
self.r = r
self.w = w
else:
Expand All @@ -158,7 +158,7 @@ def __init__(self, r, w):
def send(self, msg):
#l = len(ppc.b_(msg)) if (self.has_wb or self.w.mode == 'wb') else len(ppc.str_(msg))
#open('/tmp/pp.debug', 'a+').write(repr(('s', l, self.w, msg))+'\n')
if self.has_wb or self.w.mode == 'wb':
if self.has_wb or (hasattr(self.w, 'mode') and self.w.mode == 'rb'):
msg = ppc.b_(msg)
self.wb.write(struct.pack("!Q", len(msg)))
self.w.flush()
Expand All @@ -173,7 +173,7 @@ def receive(self, preprocess=None):
e_size = struct.calcsize("!Q") # 8
c_size = struct.calcsize("!c") # 1
r_size = 0
stub = ppc.b_("") if (self.has_rb or self.r.mode == 'rb') else ""
stub = ppc.b_("") if (self.has_rb or (hasattr(self.r, 'mode') and self.r.mode == 'rb')) else ""
data = stub
while r_size < e_size:
msg = self.rb.read(e_size-r_size)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
stable_version = '1.6.6.1'
target_version = '1.6.6.2'
is_release = stable_version == target_version
VERSION = stable_version if is_release else target_version + '.dev0'
VERSION = stable_version if is_release else target_version + '.dev1'
# os.chdir(pkgdir)
# sys.path.insert(0, '.')
# from ppcommon import __version__ as VERSION
Expand Down