Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python zeromq timeout

import time
import zmq
context = zmq.Context()

sender = context.socket(zmq.PUSH)
sender.bind("tcp://127.0.0.1:5557")

# add this
sender.setsockopt(zmq.LINGER, 0)
sender.setsockopt(zmq.RCVTIMEO, 2000) # timeout after 2s
sender.setsockopt(zmq.SNDTIMEO, 2000) # timeout after 2s
###

# exemple
i=0
while True:
    i=i+1
    time.sleep(0.5)
    print(f"sending message {i} ", end='')
    try:
        sender.send(i)
        print("succeed")
    except zmq.ZMQError as e:
        print("failed")
Comment

PREVIOUS NEXT
Code Example
Python :: python print over the same line 
Python :: rscript convert r to python script 
Python :: pomodoro timer in python 
Python :: summation 
Python :: python you bad 
Python :: osrm python 
Python :: how to deploy to shinyapps.io 
Python :: Add dj_database_url on heroku or production 
Python :: if statement in python with sets 
Python :: list devices python 3 
Python :: tekinter python 
Python :: find number of x greater than threshold in list python 
Python :: What is StringIndexer , VectorIndexer, and how to use them? 
Python :: concatenating ols model results 
Python :: "Token" is not defined Pylance 
Python :: print("ola") 
Python :: scipy random seed 
Python :: should i learn c++ or python 
Python :: geopandas change dtype of a columns 
Python :: python project pick text color according to background 
Python :: alan watts 
Python :: Ordering column names sensibly in pandas 
Python :: Pte or Pvt 
Python :: python amino acid dictionary 
Python :: python time range monthly 
Python :: map dataframe parallel 
Python :: dynamo python template path 
Python :: filter outside queryset in list django 
Python :: python cat binary files together 
Python :: find average of list via for loop python 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =