[Bug 2164882] Review Request: python3-pyrate_limiter - The request rate limiter using Leaky-bucket algorithm.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=2164882



--- Comment #6 from Steve Cossette <farchord@xxxxxxxxx> ---
Thanks for all the work, I'm guessing it wasn't easy to investigate all of
this. I'm still new to packaging python packages.

I applied all your changes and refreshed the sources. Building on f37 works,
but when I build on rawhide using fedora-review, python tests fail with this:

=================================== FAILURES
===================================
______________ test_concurrency[ProcessPoolExecutor-SQLiteBucket]
______________
concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib64/python3.11/concurrent/futures/process.py", line 256, in
_process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/concurrent/futures/process.py", line 205, in
_process_chunk
    return [fn(*args) for args in chunk]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/concurrent/futures/process.py", line 205, in
<listcomp>
    return [fn(*args) for args in chunk]
            ^^^^^^^^^
  File
"/builddir/build/BUILD/PyrateLimiter-103252ca8d5336dc19b69fda6b65798eac932fd2/tests/test_concurrency.py",
line 75, in _send_request
    with limiter.ratelimit(*bucket_ids, delay=True):
  File
"/builddir/build/BUILD/PyrateLimiter-103252ca8d5336dc19b69fda6b65798eac932fd2/pyrate_limiter/limit_context_decorator.py",
line 66, in __enter__
    self.delayed_acquire()
  File
"/builddir/build/BUILD/PyrateLimiter-103252ca8d5336dc19b69fda6b65798eac932fd2/pyrate_limiter/limit_context_decorator.py",
line 82, in delayed_acquire
    self.try_acquire()
  File
"/builddir/build/BUILD/PyrateLimiter-103252ca8d5336dc19b69fda6b65798eac932fd2/pyrate_limiter/limiter.py",
line 92, in try_acquire
    volume = bucket.size()
             ^^^^^^^^^^^^^
  File
"/builddir/build/BUILD/PyrateLimiter-103252ca8d5336dc19b69fda6b65798eac932fd2/pyrate_limiter/sqlite_bucket.py",
line 95, in size
    self._size = self._query_size()
                 ^^^^^^^^^^^^^^^^^^
  File
"/builddir/build/BUILD/PyrateLimiter-103252ca8d5336dc19b69fda6b65798eac932fd2/pyrate_limiter/sqlite_bucket.py",
line 100, in _query_size
    return self.connection.execute(f"SELECT COUNT(*) FROM
{self.table}").fetchone()[0]
           ^^^^^^^^^^^^^^^
  File
"/builddir/build/BUILD/PyrateLimiter-103252ca8d5336dc19b69fda6b65798eac932fd2/pyrate_limiter/sqlite_bucket.py",
line 73, in connection
    self._connection.execute(
sqlite3.OperationalError: database is locked
"""
The above exception was the direct cause of the following exception:
executor_class = <class 'concurrent.futures.process.ProcessPoolExecutor'>
bucket_class = <class 'pyrate_limiter.sqlite_bucket.SQLiteBucket'>
    @pytest.mark.parametrize("bucket_class", [SQLiteBucket])
    @pytest.mark.parametrize("executor_class", [ThreadPoolExecutor,
ProcessPoolExecutor])
    def test_concurrency(executor_class, bucket_class):
        """Make a fixed number of concurrent requests using a shared Limiter,
and check the total time
        they take to run
        """
        logger.info(f"Testing {bucket_class.__name__} with
{executor_class.__name__}")

        # Set up limiter
        bucket_kwargs = {
            "path": join(gettempdir(),
f"test_{executor_class.__name__}.sqlite"),
        }
        limiter = Limiter(
            RequestRate(LIMIT_REQUESTS_PER_SECOND, Duration.SECOND),
            bucket_class=bucket_class,
            bucket_kwargs=bucket_kwargs,
        )

        # Set up request function
        bucket_ids = [f"{executor_class.__name__}_bucket_{i}" for i in
range(N_BUCKETS)]
        start_time = perf_counter()
        request_func = partial(_send_request, limiter, bucket_ids, start_time)

        # Distribute requests across workers
        with executor_class(max_workers=N_WORKERS) as executor:
>           list(executor.map(request_func, range(N_REQUESTS), timeout=300))
tests/test_concurrency.py:57: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.11/concurrent/futures/process.py:597: in
_chain_from_iterable_of_lists
    for element in iterable:
/usr/lib64/python3.11/concurrent/futures/_base.py:621: in result_iterator
    yield _result_or_cancel(fs.pop(), end_time - time.monotonic())
/usr/lib64/python3.11/concurrent/futures/_base.py:317: in _result_or_cancel
    return fut.result(timeout)
/usr/lib64/python3.11/concurrent/futures/_base.py:449: in result
    return self.__get_result()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = None
    def __get_result(self):
        if self._exception:
            try:
>               raise self._exception
E               sqlite3.OperationalError: database is locked
/usr/lib64/python3.11/concurrent/futures/_base.py:401: OperationalError
----------------------------- Captured stderr call
-----------------------------
INFO:pyrate_limiter.tests:Testing SQLiteBucket with ProcessPoolExecutor
------------------------------ Captured log call
-------------------------------
INFO     pyrate_limiter.tests:test_concurrency.py:38 Testing SQLiteBucket with
ProcessPoolExecutor
=========================== short test summary info
============================
FAILED
tests/test_concurrency.py::test_concurrency[ProcessPoolExecutor-SQLiteBucket]
=================== 1 failed, 54 passed in 209.79s (0:03:29)
===================

This doesn't happen on f37 though so I'm not even sure what database it's
talking about

Thanks again for your help!


-- 
You are receiving this mail because:
You are always notified about changes to this product and component
You are on the CC list for the bug.
https://bugzilla.redhat.com/show_bug.cgi?id=2164882
_______________________________________________
package-review mailing list -- package-review@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to package-review-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/package-review@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite Conditions]     [KDE Users]

  Powered by Linux