I test python socket programming. And Modify the options as shown below was in Mac
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 100000
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 709
virtual memory (kbytes, -v) unlimited
But The following error has occurred.
Traceback (most recent call last):
File "ssub.py", line 63, in createMqttClient
rc = mqttc.loop()
File "/Library/Python/2.7/site-packages/mosquitto.py", line 633, in loop
socklist = select.select(rlist, wlist, [], timeout)
**ValueError: filedescriptor out of range in select()**
increase the filedescriptor how to write select ()
function?
There is a limit to the number of file descriptors that select()
supports - the easiest solution is to simply use poll() instead, which doesn't suffer from this limit.
Strictly speaking, select()
is limited in the highest file descriptor it can support, as opposed to the number of them in a given call - see the start of the Notes section of the select() manpage. I'm not sure what FD_SETSIZE
is on OSX, but on Linux it's 1024. There's no practical way to increase this limit from Python.
As an aside, if you want to keep things portable you might consider using something like pyev which is a Python wrapper around libev
library which uses the optimal method of waiting for IO on a given platform.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With