1

I've compiled Python 2.7.10 and Vim 7.4 with Python support (HP-UX 11.31 ia64). Everything seems to be working well except for threads. Here's simple example.

from threading import Thread
from time import sleep

def threaded_function(arg):
    for i in range(arg):
        print i
        sleep(1)

def start_thread():
    thread = Thread(target = threaded_function, args=(5, ))
    thread.start()

if __name__ == '__main__':
    start_thread()

Python interpreter executes it perfectly well.

% python thread.py
0
1
2
3
4

But Vim produces an error when I'm trying to source it (enclosed in python << EOF / EOF brackets):

Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "<string>", line 11, in start_thread
  File "/home/users/zemtsoe/local/lib/python2.7/threading.py", line 745, in start
    _start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

AFAIK Python threads are available (despite Vim thread-unsafety). Also I'm unable to use YCM plugin because of this error. What can I do?

  • So you're running the above script from inside Vim? Or outside Vim (ie. as python thread_test.py)? – Martin Tournoij Sep 13 '15 at 1:04
  • Over here I've used the thread module (_thread in Python 3) with success on Linux .. . Perhaps you can try to use that rather than the more high-level threading? – Martin Tournoij Sep 13 '15 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.