* flake8: noqa the Python 2-only builtin cmp()
* flake8: buffer() was removed in Python 3
* flake8: unicode() was removed in Python3 because all str are Unicode
Adds the modifications from #1227
* buffer() was removed in Python 3 so use memoryview
https://docs.python.org/2.7/library/stdtypes.html#memoryview-type
* buffer = bytes on Python 3
* from kombu.five import buffer
* buffer --> buffer_t
* @patch('buffer_t') in test_qpid.py
* @patch('kombu.five.buffer_t')
* Use buffer on legacy Python and bytes on Python
* Update test_qpid.py
* tox.ini: Lint on Python, not on legacy Python
* Travis CI: Lint on Python, not on legacy Python
* Update .travis.yml
* Update .travis.yml
Co-authored-by: Omer Katz <omer.drow@gmail.com>
* flakeplus only works on legacy Python
Co-authored-by: Omer Katz <omer.drow@gmail.com>
* Fix for the issue #1172
* Unit test for the fix relating to the issue #1172
* Fix for issue #1198: Celery crashes in cases where there aren’t enough available workers to start acting on “in-flight” messages in the SQS queue
* Fix for issue #1198: fixed lint issues
* Fix for issue #1198: added unit tests
Co-authored-by: inauros <inauros@copyright.com>
Although a race condition in the SQLAlchmey Channel class was fixed in
a recent commit [0], a few other methods are also susceptible to race
conditions.
Indeed, if multiple threads call the class' `_open` method, a conflict
can occur with the `metadata.create_all` call which creates the schema
in the database, resulting in an exception which can look like this:
```
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation)
duplicate key value violates unique constraint
"pg_type_typname_nsp_index" DETAIL: Key (typname,
typnamespace)=(queue_id_sequence, 2200) already exists.
```
Similarly, `_get_or_create` is susceptible to a race condition if two
threads try to create the unique queue object in the database at the
same time, resulting in this kind of exception:
```
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation)
duplicate key value violates unique constraint "kombu_queue_name_key"
DETAIL: Key (name)=(celery) already exists.
[SQL: INSERT INTO kombu_queue (id, name) VALUES
(nextval('queue_id_sequence'), %(name)s) RETURNING kombu_queue.id]
[parameters: {'name': 'celery'}]
```
By using the mutex, we can ensure that only one thread at a time
executes these critical sections, eliminating the race conditions.
The mutex has been made re-entrant since `_open` can be called from
`_get_or_create`, which would cause a deadlock if a simple `Lock` was
used instead of `RLock`.
[0] 8f1de37a08
Signed-off-by: Antoine Busque <antoinebusque@gmail.com>