File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212from . import quasixml as ET_quasi_xml
1313from collections import namedtuple
1414import os
15+ import fcntl
1516import ast
1617import threading
1718from irods .message .message import Message
@@ -150,19 +151,23 @@ def ET(xml_type = 0, server_version = None):
150151 UNICODE = str
151152
152153
154+
155+ # Necessary for older python (<3.7):
156+ _socket_is_blocking = (lambda self : 0 == fcntl .fcntl (self .fileno (), fcntl .F_GETFL ) & os .O_NONBLOCK )
157+
153158def _recv_message_in_len (sock , size ):
154159 size_left = size
155160 retbuf = None
156161
157162 # Get socket properties for debug and exception messages.
158163 host , port = sock .getpeername ()
159- is_blocking = sock . getblocking ( )
164+ is_blocking = _socket_is_blocking ( sock )
160165 timeout = sock .gettimeout ()
161166
162- logger .debug (f 'host: { host } ' )
163- logger .debug (f 'port: { port } ' )
164- logger .debug (f 'is_blocking: { is_blocking } ' )
165- logger .debug (f 'timeout: { timeout } ' )
167+ logger .debug ('host: %s' , host )
168+ logger .debug ('port: %d' , port )
169+ logger .debug ('is_blocking: %s' , is_blocking )
170+ logger .debug ('timeout: %s' , timeout )
166171
167172 while size_left > 0 :
168173 try :
Original file line number Diff line number Diff line change @@ -41,12 +41,17 @@ def test_failed_connection(self):
4141 # set port back
4242 self .sess .pool .account .port = saved_port
4343
44- def test_send_failure (self ):
44+ def test_1_multiple_disconnect (self ):
4545 with self .sess .pool .get_connection () as conn :
46- # try to close connection twice, 2nd one should fail
46+ # disconnect() may now be called multiple times without error.
47+ # (Note, here it is called implicitly upon exiting the with-block.)
4748 conn .disconnect ()
48- with self .assertRaises (NetworkException ):
49- conn .disconnect ()
49+
50+ def test_2_multiple_disconnect (self ):
51+ conn = self .sess .pool .get_connection ()
52+ # disconnect() may now be called multiple times without error.
53+ conn .disconnect ()
54+ conn .disconnect ()
5055
5156 def test_reply_failure (self ):
5257 with self .sess .pool .get_connection () as conn :
Original file line number Diff line number Diff line change 1010import time
1111import json
1212import unittest
13+ import socket
1314import irods .test .helpers as helpers
1415from irods .connection import DESTRUCTOR_MSG
1516
@@ -244,6 +245,10 @@ def test_no_refresh_connection(self):
244245 # Test to confirm the connection destructor log message is actually
245246 # logged to file, to confirm the destructor is called
246247 def test_connection_destructor_called (self ):
248+
249+ if self .sess .host != socket .gethostname () and not LOCALHOST_REGEX .match (self .sess .host ):
250+ self .skipTest ('local test only - client dot does not like the extra logging' )
251+
247252 # Set 'irods_connection_refresh_time' to '3' (in seconds) in
248253 # ~/.irods/irods_environment.json file. This means any connection
249254 # that was created more than 3 seconds ago will be dropped and
You can’t perform that action at this time.
0 commit comments