I've got this virtually "Hello world" server:
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)
Any attempt but the very first ends up like this, quite naturally:
$ 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
All I want is to check the address, kill the abortive script, and get rid of the stack trace. Somehow I did not manage to find a usable answer. What am I supposed to do?