Beispiel #1
0
 def process_request(self, unused_request):
   """Called by Django before deciding which view to execute."""
   # Compare to the first half of toplevel() in context.py.
   tasklets._state.clear_all_pending()
   # Create and install a new context.
   ctx = tasklets.make_default_context()
   tasklets.set_context(ctx)
Beispiel #2
0
    def SetupContextCache(self):
        """Set up the context cache.

            We only need cache active when testing the cache, so the default behavior
            is to disable it to avoid misleading test results. Override this when
            needed.
            """
        ctx = tasklets.make_default_context()
        tasklets.set_context(ctx)
        ctx.set_cache_policy(False)
        ctx.set_memcache_policy(False)
def cause_problem():
  tb = testbed.Testbed()
  tb.activate()
  tb.init_datastore_v3_stub()
  tb.init_memcache_stub()
  ctx = tasklets.make_default_context()
  tasklets.set_context(ctx)
  ctx.set_datastore_policy(True)
  ctx.set_cache_policy(False)
  ctx.set_memcache_policy(True)

  @tasklets.tasklet
  def problem_tasklet():
    class Foo(model.Model):
      pass
    key = yield ctx.put(Foo())
    yield ctx.get(key)  # Trigger get_tasklet that does not complete...
    yield ctx.delete(key)  # ... by the time this delete_tasklet starts.
    a = yield ctx.get(key)
    assert a is None, '%r is not None' % a

  problem_tasklet().check_success()
  print 'No problem yet...'
  tb.deactivate()
Beispiel #4
0
def cause_problem():
  tb = testbed.Testbed()
  tb.activate()
  tb.init_datastore_v3_stub()
  tb.init_memcache_stub()
  ctx = tasklets.make_default_context()
  tasklets.set_context(ctx)
  ctx.set_datastore_policy(True)
  ctx.set_cache_policy(False)
  ctx.set_memcache_policy(True)

  @tasklets.tasklet
  def problem_tasklet():
    class Foo(model.Model):
      pass
    key = yield ctx.put(Foo())
    yield ctx.get(key)  # Trigger get_tasklet that does not complete...
    yield ctx.delete(key)  # ... by the time this delete_tasklet starts.
    a = yield ctx.get(key)
    assert a is None, '%r is not None' % a

  problem_tasklet().check_success()
  print 'No problem yet...'
  tb.deactivate()