pgiri / dispy

Distributed and Parallel Computing Framework with / for Python
https://dispy.org
Other
260 stars 55 forks source link

Darwin is just one of the BSDs #141

Open UnitedMarsupials-zz opened 6 years ago

UnitedMarsupials-zz commented 6 years ago

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 commented 6 years ago

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

pgiri commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.