dispy icon indicating copy to clipboard operation
dispy copied to clipboard

Darwin is just one of the BSDs

Open UnitedMarsupials-zz opened this issue 7 years ago • 4 comments

Apple's Darwin is just one of the many BSD-derived systems, which are all particular about certain networking things. Wherever you are testing for "darwin", you should instead be testing for all of these.

For example, for dispynode.py to come up properly on FreeBSD, the following patch is necessary:

--- dispynode.py   2018-08-14 09:54:12.000000000 -0400
+++ dispynode.py   2018-08-28 17:36:56.502214000 -0400
@@ -367,5 +367,11 @@
             if os.name == 'nt':
                 bind_addr = addrinfo.ip
-            elif sys.platform == 'darwin':
+            elif platform.system() in [
+                'Darwin',
+                'DragonFlyBSD',
+                'FreeBSD',
+                'OpenBSD',
+                'NetBSD'
+            ]:
                 if addrinfo.family == socket.AF_INET and (not self.ipv4_udp_multicast):
                     bind_addr = ''

Because the same check is needed in multiple places (dispy, dispynode, dispyrelay, dispyscheduler), under both py2/ and py3/, it may be best to hide the list under a helper-function. Oh, and pycos has the same problem in its own two netpycos.py.

Not sure, how to best fix it...

I would also recommend the following hunk:

@@ -498,5 +504,9 @@
             yield task.sleep(0.2)
 
-        udp_sock.bind((bind_addr, self.port))
+        try:
+            udp_sock.bind((bind_addr, self.port))
+        except Exception as e:
+            _dispy_logger.error('Exception trying to bind to %s:%d: %s', bind_addr, self.port, e)
+            raise e
         if addrinfo.family == socket.AF_INET:
             if self.ipv4_udp_multicast:

UnitedMarsupials-zz avatar Aug 28 '18 22:08 UnitedMarsupials-zz

FWIW, I just added a work-around for this problem to FreeBSD ports for both dispy and pycos.

UnitedMarsupials-zz avatar Aug 28 '18 22:08 UnitedMarsupials-zz

I am wondering if I should handle it in a single place (perhaps with AddrInfo structure). I will commit fix in the next couple of days. Thanks again.

pgiri avatar Sep 05 '18 02:09 pgiri

As mentioned above, I applied the fix in AddrInfo structure so it actually simplifies all uses. I will apply similar patch for pycos as well. I only tested with OS X. Please let me know if this works for you.

pgiri avatar Sep 07 '18 00:09 pgiri

I have committed changes to pycos as well. Please let me know if both packages work for you. You can use examples in pycos to test; e.g,. run dispycosnode.py on a node and run dispycos_*.py programs, possibly with different combinations of network setup, such as ipv4, ipv4_udp_multicast option, ipv6 etc.

pgiri avatar Sep 08 '18 14:09 pgiri