dispy icon indicating copy to clipboard operation
dispy copied to clipboard

HTTP server example returns 'ERR_EMPTY_RESPONSE'

Open efredericks opened this issue 5 years ago • 1 comments

I'm trying to get the web monitoring running using the example in the documentation:

# example program that sends object instances in local program
# as arguments to distributed computation
class C(object):
    def __init__(self, s, i):
        self.s = s
        self.i = i
    # provide __str__ so instances of C are shown with useful info
    # when monitoring jobs in 'Node' page
    def __str__(self):
        return 'C(%s, %.4f)' % (self.s, self.i)

def compute(obj, n=5):
    # obj is an instance of C
    import time
    time.sleep(n)
    return n * obj.i

if __name__ == '__main__':
    import dispy, random

    # create cluster
    cluster = dispy.JobCluster(compute, depends=[C])

    # import dispy's httpd module, create http server for this cluster
    import dispy.httpd
    http_server = dispy.httpd.DispyHTTPServer(cluster)

    # cluster can now be monitored / managed in web browser at
    # http://<host>:8181 where <host> is name or IP address of
    # computer running this program

    for i in range(8): # submit jobs to cluster
        c = C(str(i), random.uniform(1, 9))
        job = cluster.submit(c, n=random.randint(5, 20))
        job.id = i

    cluster.wait() # wait for all jobs to finish
    http_server.shutdown() # this waits until browser gets all updates
    cluster.close()

However, I receive an empty response from the browser when visiting the IP. I've tried also specifying the IP address, changing the port, ensuring the firewall was open, etc. When I try to visit the host on a different port I receive the expected connection refused, as nothing is running there, but get the empty response from the example.

I have a similar issue when trying on a 'real' program as well. Software is running on Python 3 on Raspberry Pi 3B's (Raspbian Buster).

efredericks avatar May 11 '20 13:05 efredericks

Apparently httpd module in 'py3' branch is broken since 4.11.0 version - the white space (indentation) is messed up. I will release new version with the fix in couple of days. However, httpd.py from 'py2' branch can be used with Python 3, so you can simply copy that file (from 'py2') to dispy's installation path for Python 3.

pgiri avatar May 12 '20 02:05 pgiri