comparison src/testdir/test87.in @ 4109:3b2a771abb39 v7.3.808

updated for version 7.3.808 Problem: Python threads still do not work properly. Solution: Fix both Python 2 and 3. Add tests. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Wed, 13 Feb 2013 14:17:08 +0100
parents fd6ef931aa77
children f1eab4f77a6f
comparison
equal deleted inserted replaced
4108:be70761a9a89 4109:3b2a771abb39
265 : catch 265 : catch
266 : let toput=e.":\t".v:exception[:13] 266 : let toput=e.":\t".v:exception[:13]
267 : $put =toput 267 : $put =toput
268 : endtry 268 : endtry
269 :endfor 269 :endfor
270 :"
271 :" threading
272 :let l = [0]
273 :py3 l=vim.bindeval('l')
274 :py3 <<EOF
275 import threading
276 import time
277
278 class T(threading.Thread):
279 def __init__(self):
280 threading.Thread.__init__(self)
281 self.t = 0
282 self.running = True
283
284 def run(self):
285 while self.running:
286 self.t += 1
287 time.sleep(0.1)
288
289 t = T()
290 t.start()
291 EOF
292 :sleep 1
293 :py3 t.running = False
294 :py3 t.join()
295 :py3 l[0] = t.t > 8 # check if the background thread is working
296 :$put =string(l)
297 :"
298 :" settrace
299 :let l = []
300 :py3 l=vim.bindeval('l')
301 :py3 <<EOF
302 import sys
303
304 def traceit(frame, event, arg):
305 global l
306 if event == "line":
307 l += [frame.f_lineno]
308 return traceit
309
310 def trace_main():
311 for i in range(5):
312 pass
313 EOF
314 :py3 sys.settrace(traceit)
315 :py3 trace_main()
316 :py3 sys.settrace(None)
317 :$put =string(l)
270 :endfun 318 :endfun
271 :" 319 :"
272 :call Test() 320 :call Test()
273 :" 321 :"
274 :delfunc Test 322 :delfunc Test