Example unixsocket_server.py#

 1# gevent-test-requires-resource: unixsocket_client
 2import os
 3from gevent.pywsgi import WSGIServer
 4from gevent import socket
 5
 6
 7def application(environ, start_response):
 8    assert environ
 9    start_response('200 OK', [])
10    return []
11
12
13if __name__ == '__main__':
14    listener = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
15    sockname = './' + os.path.basename(__file__) + '.sock'
16    if os.path.exists(sockname):
17        os.remove(sockname)
18    listener.bind(sockname)
19    listener.listen(1)
20    WSGIServer(listener, application).serve_forever()

Current source