internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: celery/kombu

Issue:
Virtual transport timeout does not supesede period polling
If period polling is large and timeout is small, periodic polling should not exceed timeout.



Discussion:

Resolving patch:
diff --git a/kombu/transport/virtual/base.py b/kombu/transport/virtual/base.py
--- a/kombu/transport/virtual/base.py
+++ b/kombu/transport/virtual/base.py
@@ -956,6 +956,8 @@ def drain_events(self, connection, timeout=None):
         time_start = monotonic()
         get = self.cycle.get
         polling_interval = self.polling_interval
+        if timeout and polling_interval and polling_interval > timeout:
+            polling_interval = timeout
         while 1:
             try:
                 get(self._deliver, timeout=timeout)


Test patch:
diff --git a/t/unit/transport/virtual/test_base.py b/t/unit/transport/virtual/test_base.py
--- a/t/unit/transport/virtual/test_base.py
+++ b/t/unit/transport/virtual/test_base.py
@@ -4,6 +4,7 @@
 import pytest
 import sys
 import warnings
+import socket
 
 from case import MagicMock, Mock, patch
 
@@ -12,6 +13,7 @@
 from kombu.exceptions import ResourceError, ChannelError
 from kombu.transport import virtual
 from kombu.utils.uuid import uuid
+from kombu.five import monotonic
 
 PY3 = sys.version_info[0] == 3
 PRINT_FQDN = 'builtins.print' if PY3 else '__builtin__.print'
@@ -556,6 +558,13 @@ def test_custom_polling_interval(self):
         x = client(transport_options=dict(polling_interval=32.3))
         assert x.transport.polling_interval == 32.3
 
+    def test_timeout_over_polling_interval(self):
+        x = client(transport_options=dict(polling_interval=60))
+        start = monotonic()
+        with pytest.raises(socket.timeout):
+            x.transport.drain_events(x, timeout=.5)
+            assert monotonic() - start < 60
+
     def test_close_connection(self):
         c1 = self.transport.create_channel(self.transport)
         c2 = self.transport.create_channel(self.transport)
Repository: celery/kombu

Issue:
SQS Channel doesn't support 'callback' kwarg 
SQS Channel doesn't seem to support the 'callback' kwarg.  
```
  File "/Users/mich9038/Git/cloud-daemon/scripts/../cloud_daemon/__init__.py", line 44, in run
    connection.drain_events()
  File "/Users/mich9038/.pyenv/versions/cloud-daemon/lib/python3.6/site-packages/kombu/connection.py", line 301, in drain_events
    return self.transport.drain_events(self.connection, **kwargs)
  File "/Users/mich9038/.pyenv/versions/cloud-daemon/lib/python3.6/site-packages/kombu/transport/virtual/base.py", line 961, in drain_events
    get(self._deliver, timeout=timeout)
  File "/Users/mich9038/.pyenv/versions/cloud-daemon/lib/python3.6/site-packages/kombu/utils/scheduling.py", line 56, in get
    return self.fun(resource, callback, **kwargs)
  File "/Users/mich9038/.pyenv/versions/cloud-daemon/lib/python3.6/site-packages/kombu/transport/virtual/base.py", line 999, in _drain_channel
    return channel.drain_events(callback=callback, timeout=timeout)
TypeError: drain_events() got an unexpected keyword argument 'callback'
```

Am I just implementing this transport incorrectly?

https://github.com/celery/kombu/blob/master/kombu/transport/SQS.py#L135

Literally changing to 

```
 def drain_events(self, timeout=None, **kwargs):
```

Allows the SQS transport to function properly.

With code such as this:

```
        jobs_exchange = Exchange(CONFIG.TRANSPORT_EXCHANGE, 'direct', durable=True)
        jobs_queue = Queue(CONFIG.TRANPORT_ROUTING_KEY, exchange=jobs_exchange, routing_key=CONFIG.TRANPORT_ROUTING_KEY)
        with Connection(CONFIG.TRANSPORT_URI, transport='sqs', transport_options={'region': 'us-west-2'}) as connection:
            with connection.Consumer(jobs_queue, callbacks=[self._consume_message]):
                while True:
                    connection.drain_events()

```

Where TRANSPORT_URI is 
```
CONFIG.TRANSPORT_URI = 'sqs://'
```

AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY are set using environment variables.



Discussion:

Resolving patch:
diff --git a/kombu/transport/SQS.py b/kombu/transport/SQS.py
--- a/kombu/transport/SQS.py
+++ b/kombu/transport/SQS.py
@@ -132,7 +132,7 @@ def basic_cancel(self, consumer_tag):
             self._noack_queues.discard(queue)
         return super(Channel, self).basic_cancel(consumer_tag)
 
-    def drain_events(self, timeout=None):
+    def drain_events(self, timeout=None, **kwargs):
         """Return a single payload message from one of our queues.
 
         Raises:


Test patch:
Repository: celery/kombu

Issue:
TypeError: basic_ack() got an unexpected keyword argument 'multiple' while using Qpid with Kombu
Full traceback:

```
Pending callback raised: TypeError("basic_ack() got an unexpected keyword argument 'multiple'",)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/celery/worker/consumer/consumer.py", line 233, in perform_pending_operations
    self._pending_operations.pop()()
  File "/usr/lib/python2.7/site-packages/vine/promises.py", line 139, in __call__
    return self.throw()
  File "/usr/lib/python2.7/site-packages/vine/promises.py", line 136, in __call__
    retval = fun(*final_args, **final_kwargs)
  File "/usr/lib/python2.7/site-packages/kombu/message.py", line 131, in ack_log_error
    self.ack(multiple=multiple)
  File "/usr/lib/python2.7/site-packages/kombu/message.py", line 125, in ack
    self.channel.basic_ack(self.delivery_tag, multiple=multiple)
TypeError: basic_ack() got an unexpected keyword argument 'multiple'
```

In the last line, "self.channel" is a ```kombu.transport.qpid.Channel``` object as revealed in debugging.  The ```basic_ack``` method on the qpid.Channel does not provide the ```multiple``` keyword argument.

https://github.com/celery/kombu/blob/958ed450f6a559e33627a5d02ca67b3d31c49106/kombu/message.py#L125

https://github.com/celery/kombu/blob/474a4be4062de4546632a3104a69bf8f6a60e0ba/kombu/transport/qpid.py#L853


Kombu 4.0.2
Celery 4.0.2
Vine 1.1.3
AMQP 2.1.4
qpid-python 1.3.5


Discussion:

Resolving patch:
diff --git a/kombu/transport/qpid.py b/kombu/transport/qpid.py
--- a/kombu/transport/qpid.py
+++ b/kombu/transport/qpid.py
@@ -850,7 +850,7 @@ def basic_get(self, queue, no_ack=False, **kwargs):
         except Empty:
             pass
 
-    def basic_ack(self, delivery_tag):
+    def basic_ack(self, delivery_tag, multiple=False):
         """Acknowledge a message by delivery_tag.
 
         Acknowledges a message referenced by delivery_tag. Messages can
@@ -864,8 +864,12 @@ def basic_ack(self, delivery_tag):
         :param delivery_tag: The delivery tag associated with the message
             to be acknowledged.
         :type delivery_tag: uuid.UUID
+        :param multiple: not implemented. If set to True an AssertionError
+            is raised.
+        :type multiple: bool
 
         """
+        assert multiple is False
         self.qos.ack(delivery_tag)
 
     def basic_reject(self, delivery_tag, requeue=False):


Test patch:
Repository: celery/kombu

Issue:
Use passwords passed in "redis+socket://" URLs.
This is the same issue as #460 but happening in the 4.x series now. Steps to reproduce and workarounds are the same as in the earlier bug report, and I suspect the code fix is similar, if not identical.

### Versions

Kombu version: 4.0.2
OS: Debian testing up to date as of 2016-12-28.



Discussion:
I see the same thing.
It seems that the [change](https://github.com/celery/kombu/commit/d720d33a9b6be617d9e083f639b0159cdd00ebae) with the fix is somehow not anymore present in the [master branch](https://github.com/celery/kombu/blob/master/kombu/transport/redis.py#L897). 

@lddubeau yes the fix should be the same probably, but a simple unit test that covers this issue should also be added.

Resolving patch:
diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py
--- a/kombu/transport/redis.py
+++ b/kombu/transport/redis.py
@@ -894,7 +894,7 @@ def _connparams(self, async=False):
                 pass
         host = connparams['host']
         if '://' in host:
-            scheme, _, _, _, _, path, query = _parse_url(host)
+            scheme, _, _, _, password, path, query = _parse_url(host)
             if scheme == 'socket':
                 connparams = self._filter_tcp_connparams(**connparams)
                 connparams.update({
@@ -904,6 +904,7 @@ def _connparams(self, async=False):
                 connparams.pop('socket_connect_timeout', None)
                 connparams.pop('socket_keepalive', None)
                 connparams.pop('socket_keepalive_options', None)
+            connparams['password'] = password
 
             connparams.pop('host', None)
             connparams.pop('port', None)


Test patch:
diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py
--- a/t/unit/transport/test_redis.py
+++ b/t/unit/transport/test_redis.py
@@ -663,6 +663,20 @@ def test_connparams_regular_hostname(self):
         self.channel.connection.client.hostname = 'george.vandelay.com'
         assert self.channel._connparams()['host'] == 'george.vandelay.com'
 
+    def test_connparams_password_for_unix_socket(self):
+        self.channel.connection.client.hostname = \
+            'socket://:foo@/var/run/redis.sock'
+        connection_parameters = self.channel._connparams()
+        password = connection_parameters['password']
+        path = connection_parameters['path']
+        assert (password, path) == ('foo', '/var/run/redis.sock')
+        self.channel.connection.client.hostname = \
+            'socket://@/var/run/redis.sock'
+        connection_parameters = self.channel._connparams()
+        password = connection_parameters['password']
+        path = connection_parameters['path']
+        assert (password, path) == (None, '/var/run/redis.sock')
+
     def test_rotate_cycle_ValueError(self):
         cycle = self.channel._queue_cycle
         cycle.update(['kramer', 'jerry'])
Repository: celery/kombu

Issue:
Timer.__iter__'s docstring is error.
``kombu.async.timer.Timer.__iter__`` yields a tuple of ``(wait_seconds, entry)``, not ``(entry, wait_seconds)``.

Should I provide pr to fix such small problem?
As a newcomer, I don't know if this is appropriate?


Discussion:
You are referring to this [docstring](https://github.com/celery/kombu/blob/836512cadd23c96f23bbb5cd8f4a1bf83c36ab19/kombu/async/timer.py#L183), right? I think that you are correct, yes please, all contributions are more than welcome! :smile: 

Resolving patch:
diff --git a/kombu/async/timer.py b/kombu/async/timer.py
--- a/kombu/async/timer.py
+++ b/kombu/async/timer.py
@@ -180,7 +180,7 @@ def __iter__(self, min=min, nowfun=monotonic,
                  pop=heapq.heappop, push=heapq.heappush):
         """Iterate over schedule.
 
-        This iterator yields a tuple of ``(entry, wait_seconds)``,
+        This iterator yields a tuple of ``(wait_seconds, entry)``,
         where if entry is :const:`None` the caller should wait
         for ``wait_seconds`` until it polls the schedule again.
         """


Test patch:
Repository: celery/kombu

Issue:
ValueError: Socket not connected
Hello,
the following error happens sometimes when publishing :

```
  File "/foo/bar/lib/python2.7/site-packages/kombu/messaging.py", line 181, in publish
    exchange_name, declare,
  File "/foo/bar/lib/python2.7/site-packages/kombu/connection.py", line 506, in _ensured
    self.collect()
  File "/foo/bar/lib/python2.7/site-packages/kombu/connection.py", line 350, in collect
    gc_transport(self._connection)
  File "/foo/bar/lib/python2.7/site-packages/kombu/transport/librabbitmq.py", line 148, in _collect
    os.close(connection.fileno())
ValueError: Socket not connected

```

kombu==4.1.0


Discussion:
I think I might be having a similar error, just in python 3 https://github.com/celery/kombu/issues/857
Have you activated publisher retries?
Yes, I did. 


Resolving patch:
diff --git a/kombu/transport/librabbitmq.py b/kombu/transport/librabbitmq.py
--- a/kombu/transport/librabbitmq.py
+++ b/kombu/transport/librabbitmq.py
@@ -146,7 +146,7 @@ def _collect(self, connection):
                 channel.connection = None
             try:
                 os.close(connection.fileno())
-            except OSError:
+            except (OSError, ValueError):
                 pass
             connection.channels.clear()
             connection.callbacks.clear()


Test patch:
diff --git a/t/unit/transport/test_librabbitmq.py b/t/unit/transport/test_librabbitmq.py
--- a/t/unit/transport/test_librabbitmq.py
+++ b/t/unit/transport/test_librabbitmq.py
@@ -125,6 +125,18 @@ def test_collect__with_conn(self):
             self.T._collect(conn)
             close.assert_called_with(conn.fileno())
 
+    def test_collect__with_fileno_raising_value_error(self):
+        conn = Mock(name='connection')
+        conn.channels = {1: Mock(name='chan1'), 2: Mock(name='chan2')}
+        with patch('os.close') as close:
+            self.T.client = self.client
+            conn.fileno.side_effect = ValueError("Socket not connected")
+            self.T._collect(conn)
+            close.assert_not_called()
+        conn.fileno.assert_called_with()
+        assert self.client.drain_events is None
+        assert self.T.client is None
+
     def test_register_with_event_loop(self):
         conn = Mock(name='conn')
         loop = Mock(name='loop')
Repository: celery/kombu

Issue:
ambiguous typehints causing warnings building the Celery documentation
This is admittedly a minor issue.

When building the documentation for [Celery](https://github.com/celery/celery), sphinx reports autodoc warnings that the `Exchange` typehint is ambiguous in `kombu/messaging.py`


Discussion:

Resolving patch:
diff --git a/kombu/messaging.py b/kombu/messaging.py
--- a/kombu/messaging.py
+++ b/kombu/messaging.py
@@ -21,7 +21,7 @@ class Producer(object):
 
     Arguments:
         channel (kombu.Connection, ChannelT): Connection or channel.
-        exchange (Exchange, str): Optional default exchange.
+        exchange (kombu.entity.Exchange, str): Optional default exchange.
         routing_key (str): Optional default routing key.
         serializer (str): Default serializer. Default is `"json"`.
         compression (str): Default compression method.
@@ -135,7 +135,7 @@ def publish(self, body, routing_key=None, delivery_mode=None,
             compression (str): Compression method to use.  Default is none.
             headers (Dict): Mapping of arbitrary headers to pass along
                 with the message body.
-            exchange (Exchange, str): Override the exchange.
+            exchange (kombu.entity.Exchange, str): Override the exchange.
                 Note that this exchange must have been declared.
             declare (Sequence[EntityT]): Optional list of required entities
                 that must have been declared before publishing the message.


Test patch:
Repository: celery/kombu

Issue:
Improper queue name parsing for SQS FIFO queues ending with an 'f'
Due to improper use of 'rstrip' queue names ending with an 'f' will not be parsed properly
```
>>> queue_name_ending_with_an_f = 'queue_name_ending_with_an_f.fifo'
>>> queue_name_ending_with_an_f.rstrip('.fifo')
'queue_name_ending_with_an_'
>>> queue_name_ending_with_an_f.split('.')[:1][0]
'queue_name_ending_with_an_f'
>>>
```

fixed in #887 


Discussion:

Resolving patch:
diff --git a/kombu/transport/SQS.py b/kombu/transport/SQS.py
--- a/kombu/transport/SQS.py
+++ b/kombu/transport/SQS.py
@@ -57,7 +57,7 @@
 
 logger = get_logger(__name__)
 
-# dots are replaced by dash, all other punctuation
+# dots are replaced by dash, dash remains dash, all other punctuation
 # replaced by underscore.
 CHARS_REPLACE_TABLE = {
     ord(c): 0x5f for c in string.punctuation if c not in '-_.'
@@ -151,7 +151,7 @@ def _reset_cycle(self):
     def entity_name(self, name, table=CHARS_REPLACE_TABLE):
         """Format AMQP queue name into a legal SQS queue name."""
         if name.endswith('.fifo'):
-            partial = name.rstrip('.fifo')
+            partial = name[:-len('.fifo')]
             partial = text_t(safe_str(partial)).translate(table)
             return partial + '.fifo'
         else:


Test patch:
diff --git a/t/unit/transport/test_SQS.py b/t/unit/transport/test_SQS.py
--- a/t/unit/transport/test_SQS.py
+++ b/t/unit/transport/test_SQS.py
@@ -224,6 +224,12 @@ def test_none_hostname_persists(self):
         conn = Connection(hostname=None, transport=SQS.Transport)
         assert conn.hostname == conn.clone().hostname
 
+    def test_entity_name(self):
+        assert self.channel.entity_name('foo') == 'foo'
+        assert self.channel.entity_name('foo.bar-baz*qux_quux') == \
+            'foo-bar-baz_qux_quux'
+        assert self.channel.entity_name('abcdef.fifo') == 'abcdef.fifo'
+
     def test_new_queue(self):
         queue_name = 'new_unittest_queue'
         self.channel._new_queue(queue_name)
Repository: celery/kombu

Issue:
Kombu 4.3.0 Sentinel password error
Hi, I have problem with password in sentinel url after update to kombu 4.3.0.
In release was change method, witch set host and port to redis sentinel (https://github.com/celery/kombu/commit/a59b44e9fb8d00758dd6a3c560e2f158e672580d#diff-1fdc4d4a0fe8a800a42d1341599d8679R1106). If I use password in sentinel url (e.g. 'sentinel://:password@redis-sentinel:26379/0'), method `sentinel.Sentinel` is call with `[('', 'password@redis-sentinel', '26379')]` instead `[('redis-sentinel', '26379')]`

Call finish with traceback:
  File "/lib/python3.4/site-packages/kombu/transport/redis.py", line 1113, in _sentinel_managed_pool
    **additional_params)
  File "/lib/python3.4/site-packages/redis/sentinel.py", line 182, in __init__
    for hostname, port in sentinels]
  File "/lib/python3.4/site-packages/redis/sentinel.py", line 182, in <listcomp>
    for hostname, port in sentinels]
ValueError: too many values to unpack (expected 2)



Discussion:

Resolving patch:
diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py
--- a/kombu/transport/redis.py
+++ b/kombu/transport/redis.py
@@ -1102,8 +1102,9 @@ def _sentinel_managed_pool(self, asynchronous=False):
         additional_params.pop('port', None)
         connection_list = []
         for url in self.connection.client.alt:
-            if url and 'sentinel://' in url:
-                connection_list.append(url.split('/')[2].split(':'))
+            url = _parse_url(url)
+            if url.scheme == 'sentinel':
+                connection_list.append([url.hostname, str(url.port)])
         sentinel_inst = sentinel.Sentinel(
             connection_list,
             min_other_sentinels=getattr(self, 'min_other_sentinels', 0),


Test patch:
diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py
--- a/t/unit/transport/test_redis.py
+++ b/t/unit/transport/test_redis.py
@@ -1344,7 +1344,10 @@ def test_method_called(self):
     def test_getting_master_from_sentinel(self):
         with patch('redis.sentinel.Sentinel') as patched:
             connection = Connection(
-                'sentinel://localhost:65534/;sentinel://localhost:65535/;sentinel://localhost:65536/;',  # noqa: E501
+                'sentinel://localhost:65532/;'
+                'sentinel://user@localhost:65533/;'
+                'sentinel://:password@localhost:65534/;'
+                'sentinel://user:password@localhost:65535/;',
                 transport_options={
                     'master_name': 'not_important',
                 },
@@ -1353,9 +1356,10 @@ def test_getting_master_from_sentinel(self):
             connection.channel()
             patched.assert_called_once_with(
                 [
+                    [u'localhost', u'65532'],
+                    [u'localhost', u'65533'],
                     [u'localhost', u'65534'],
                     [u'localhost', u'65535'],
-                    [u'localhost', u'65536']
                 ],
                 connection_class=mock.ANY, db=0, max_connections=10,
                 min_other_sentinels=0, password=None, sentinel_kwargs=None,
Repository: archlinux/archinstall

Issue:
Confirm disk choice when multiple disks are found...



Discussion:

Resolving patch:
diff --git a/archinstall.py b/archinstall.py
--- a/archinstall.py
+++ b/archinstall.py
@@ -466,7 +466,6 @@ def random_string(l):
 		exit(1)
 
 	## Setup some defaults (in case no command-line parameters or netdeploy-params were given)
-	if not 'drive' in args: args['drive'] = sorted(list(harddrives.keys()))[0] # First drive found
 	if not 'size' in args: args['size'] = '100%'
 	if not 'start' in args: args['start'] = '513MiB'
 	if not 'pwfile' in args: args['pwfile'] = '/tmp/diskpw'
@@ -480,6 +479,12 @@ def random_string(l):
 	if not 'profiles-path' in args: args['profiles-path'] = profiles_path
 	if not 'rerun' in args: args['rerun'] = None
 	if not 'ignore-rerun' in args: args['ignore-rerun'] = False
+	if not 'localtime' in args: args['localtime'] = 'Europe/Stockholm' if args['country'] == 'SE' else 'GMT+0' # TODO: Arbitrary for now
+	if not 'drive' in args:
+		drives = list(harddrives.keys())
+		if len(drives) > 1 and 'force' not in args and ('default' in args and 'first-drive' not in args):
+			raise KeyError("Multiple disks found, --drive=/dev/X not specified (or --force/--first-drive)")
+		args['drive'] = sorted(drives)[0] # First drive found
 	rerun = args['ignore-rerun']
 
 	if args['drive'][0] != '/':
@@ -580,6 +585,9 @@ def random_string(l):
 #		if not args['password']:
 
 	print(json.dumps(args, indent=4))
+	if args['default'] and not 'force' in args:
+		if(input('Are these settings OK? (No return beyond this point) N/y: ').lower() != 'y'):
+			exit(1)
 
 	if not os.path.isfile(args['pwfile']):
 		#PIN = '0000'
@@ -722,7 +730,7 @@ def random_string(l):
 			fstab.write('\ntmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0\n') # Redundant \n at the start? who knoes?
 
 		o = b''.join(sys_command('/usr/bin/arch-chroot /mnt rm /etc/localtime').exec())
-		o = b''.join(sys_command('/usr/bin/arch-chroot /mnt ln -s /usr/share/zoneinfo/Europe/Stockholm /etc/localtime').exec())
+		o = b''.join(sys_command('/usr/bin/arch-chroot /mnt ln -s /usr/share/zoneinfo/{localtime} /etc/localtime'.format(**args)).exec())
 		o = b''.join(sys_command('/usr/bin/arch-chroot /mnt hwclock --hctosys --localtime').exec())
 		#o = sys_command('arch-chroot /mnt echo "{hostname}" > /etc/hostname'.format(**args)).exec()
 		#o = sys_command("arch-chroot /mnt sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen").exec()


Test patch: