Python:zmq.error.ZMQError:地址已在使用中

时间:2016-01-07 14:22:05

标签: python sockets bind zeromq

我实际上得到了这个" Hello world"服务器:

import time
import zmq
import mutagen
import json

context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:64108")

try:

    while True:
        #  Wait for next request from client
        message = socket.recv()
        jsn = message.decode('utf8')
        rq = json.loads(jsn)

        reply = 'Idle'

        if rq['request'] == 'settags':
            audio = mutagen.File(rq['file'], easy=True)
            if audio:
                reply = "track number set to [{}]".format(rq['tags']['tracknumber'])  # Debug info
                for tag, value in rq['tags'].items():
                    audio[tag] = value
                audio.save()
        #  Send reply back to client
        socket.send_string(reply)

except KeyboardInterrupt as e:
    sys.exit(e)

任何尝试,但第一次尝试都是这样,非常自然:

$ python /home/alexey/Dropbox/procrustes/procrserver.py 
Traceback (most recent call last):
  File "/home/alexey/Dropbox/procrustes/procrserver.py", line 20, in <module>
socket.bind("tcp://*:64108")
  File "zmq/backend/cython/socket.pyx", line 487, in zmq.backend.cython.socket.Socket.bind (zmq/backend/cython/socket.c:5156)
  File "zmq/backend/cython/checkrc.pxd", line 25, in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/socket.c:7535)
zmq.error.ZMQError: Address already in use

我想要的只是检查地址,杀死流产脚本,并摆脱堆栈跟踪。不知怎的,我没有找到一个可用的答案。我该怎么办?

0 个答案:

没有答案