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

HTTP server example returns 'ERR_EMPTY_RESPONSE' #209

Open
efredericks opened this issue May 11, 2020 · 1 comment
Open

HTTP server example returns 'ERR_EMPTY_RESPONSE' #209

efredericks opened this issue May 11, 2020 · 1 comment

Comments

@efredericks
Copy link

efredericks commented May 11, 2020

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).

@pgiri
Copy link
Owner

pgiri commented May 12, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants