Пример #1
0
 def test_get_request_states(self):
   request_state.start_request('1')
   request_state.start_request('2')
   request_state.start_request('3')
   self.assertEqual(3, len(request_state.get_request_states()))
   self.assertItemsEqual(
       [request_state.get_request_state(request_id) for
        request_id in ['1', '2', '3']], request_state.get_request_states())
Пример #2
0
  def _start_new_thread(target, args, kw=None):
    if kw is None:
      kw = {}

    request_id = remote_api_stub.RemoteStub._GetRequestId()
    request = request_state.get_request_state(request_id)

    def _run():
      try:
        remote_api_stub.RemoteStub._SetRequestId(request_id)
        request.start_thread()
        target(*args, **kw)
      finally:
        request_environment.current_request.Clear()
        request.end_thread()
    return base_start_new_thread(_run, ())
Пример #3
0
  def _start_new_thread(target, args, kw=None):
    if kw is None:
      kw = {}

    request_id = remote_api_stub.RemoteStub._GetRequestId()
    request = request_state.get_request_state(request_id)

    def _run():
      try:
        remote_api_stub.RemoteStub._SetRequestId(request_id)
        request.start_thread()
        target(*args, **kw)
      finally:
        request_environment.current_request.Clear()
        request.end_thread()
    return base_start_new_thread(_run, ())
Пример #4
0
 def test_start_request_function(self):
   request_state.start_request('id')
   self.assertEqual(1, len(request_state.get_request_states()))
   self.assertEqual('id', request_state.get_request_state('id').request_id)