File: test_backgrounding.py

package info (click to toggle)
python-dogpile.cache 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 772 kB
  • sloc: python: 5,462; makefile: 155; sh: 104
file content (24 lines) | stat: -rw-r--r-- 517 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import threading

import dogpile


class AsyncRunnerTest:
    def test_async_release(self):
        self.called = False

        def runner(mutex):
            self.called = True
            mutex.release()

        mutex = threading.Lock()
        create = lambda: ("value", 1)  # noqa
        get = lambda: ("value", 1)  # noqa
        expiretime = 1

        assert not self.called

        with dogpile.Lock(mutex, create, get, expiretime, runner) as _:
            assert self.called

        assert self.called