Guest User

Untitled

a guest
Nov 18th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #------------------
  2. # threads
  3. #------------------
  4.  
  5. def p_thread_stmts(p):
  6. '''thread_stmts : thread_start NEWLINE INDENT thread_params DEDENT'''
  7.  
  8. # append new thread to request container
  9. p.lexer.request.add_thread(p.lexer.thread)
  10.  
  11. # return
  12. p[0] = ('thread', p.lexer.thread)
  13.  
  14. def p_thread_start(p):
  15. '''thread_start : THREAD VARNAME'''
  16.  
  17. # create a new thread, and set the current thread context
  18. p.lexer.thread = RequestThread(name=p[2])
  19.  
  20. # throw away return
  21. p[0] = ('thread', p[2])
  22.  
  23. def p_thread_params(p):
  24. '''thread_params : thread_params thread_param
  25. | thread_param'''
  26. if len(p) == 3:
  27. p[0] = (p[2], p[1])
  28. else:
  29. p[0] = p[1]
  30.  
  31. def p_thread_param_task(p):
  32. '''thread_param : TASKS EQ exprlist'''
  33. p.lexer.thread.set_taskgroup_links(p[3])
  34. p[0] = ('tasks', p[3])
  35.  
  36. def p_thread_param_pop(p):
  37. '''thread_param : POP EQ NUMBER'''
  38. p.lexer.thread.set_pop(p[3])
  39. p[0] = ('pop', p[3])
  40.  
  41. def p_thread_param_rollback(p):
  42. '''thread_param : ROLLBACK EQ BOOL'''
  43. p.lexer.thread.set_rollback(p[3])
  44. p[0] = ('rollback_on_error', p[3])
Add Comment
Please, Sign In to add comment