Python cannot start a new thread, but cannot hit a thread restriction

I have an embedded system (armv5tejl AT91SAM9X25 with 128 MB of RAM, running rootros based on buildroot) with Python 3 installed. I left the system working for many days and I came to do some python development work, but it seems , There was a problem creating new threads.

If I try to run the following program:

Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> import time
>>> def func():
...     i = 0
...     while True:
...         i += 1
...         print(i)
...         time.sleep(1)
...
>>>
>>> func()
1
2
3
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 6, in func
KeyboardInterrupt
>>> t = threading.Thread(target=func)
>>> t.start()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/threading.py", line 850, in start
RuntimeError: can't start new thread
>>>

As you can see, when I try to start the stream, I get the above error. Some initial searches seem to indicate that the problem may be due to the system working with thread restrictions. Here is the output of ulimit -a:

# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 961
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 961
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

, 75, 961. :

# free -m
             total       used       free     shared    buffers     cached
Mem:           120        118          2         60          0         65
-/+ buffers/cache:         52         67
Swap:            0          0          0

, echo 1 > /proc/sys/vm/compact_memory.

, , ( ), , , .

+4
1

, Python. . Python ?

+1

Source: https://habr.com/ru/post/1658075/


All Articles