def try_acquire(self, permits=1, timeout=0):
    '\n        Tries to acquire one or the given number of permits, if they are available, and returns immediately, with the\n        value ``true``, reducing the number of available permits by the given amount.\n\n        If there are insufficient permits and a timeout is provided, the current thread becomes disabled for thread\n        scheduling purposes and lies dormant until one of following happens:\n            * some other thread invokes the release() method for this semaphore and the current thread is next to be\n            assigned a permit, or\n            * some other thread interrupts the current thread, or\n            * the specified waiting time elapses.\n\n        If there are insufficient permits and no timeout is provided, this method will return immediately with the value\n        ``false`` and the number of available permits is unchanged.\n\n        :param permits: (int), the number of permits to acquire (optional).\n        :param timeout: (long), the maximum time in seconds to wait for the permit(s) (optional).\n        :return: (bool), ``true`` if desired amount of permits was acquired, ``false`` otherwise.\n        '
    check_not_negative(permits, 'Permits cannot be negative!')
    return self._encode_invoke(semaphore_try_acquire_codec, permits=permits, timeout=to_millis(timeout))
Tries to acquire one or the given number of permits, if they are available, and returns immediately, with the
value ``true``, reducing the number of available permits by the given amount.

If there are insufficient permits and a timeout is provided, the current thread becomes disabled for thread
scheduling purposes and lies dormant until one of following happens:
    * some other thread invokes the release() method for this semaphore and the current thread is next to be
    assigned a permit, or
    * some other thread interrupts the current thread, or
    * the specified waiting time elapses.

If there are insufficient permits and no timeout is provided, this method will return immediately with the value
``false`` and the number of available permits is unchanged.

:param permits: (int), the number of permits to acquire (optional).
:param timeout: (long), the maximum time in seconds to wait for the permit(s) (optional).
:return: (bool), ``true`` if desired amount of permits was acquired, ``false`` otherwise.
def try_acquire(self, permits=1, timeout=0):
    '\n        Tries to acquire one or the given number of permits, if they are available, and returns immediately, with the\n        value ``true``, reducing the number of available permits by the given amount.\n\n        If there are insufficient permits and a timeout is provided, the current thread becomes disabled for thread\n        scheduling purposes and lies dormant until one of following happens:\n            * some other thread invokes the release() method for this semaphore and the current thread is next to be\n            assigned a permit, or\n            * some other thread interrupts the current thread, or\n            * the specified waiting time elapses.\n\n        If there are insufficient permits and no timeout is provided, this method will return immediately with the value\n        ``false`` and the number of available permits is unchanged.\n\n        :param permits: (int), the number of permits to acquire (optional).\n        :param timeout: (long), the maximum time in seconds to wait for the permit(s) (optional).\n        :return: (bool), ``true`` if desired amount of permits was acquired, ``false`` otherwise.\n        '
    check_not_negative(permits, 'Permits cannot be negative!')
    return self._encode_invoke(semaphore_try_acquire_codec, permits=permits, timeout=to_millis(timeout))