Skip to content

Commit 6341220

Browse files
author
Alexey Tsitkin
committed
fixed pr comment
1 parent 819bf63 commit 6341220

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ from eb_sqs.decorators import task
2525

2626
@task(queue_name='test')
2727
def echo(message):
28-
print message
28+
print(message)
2929

3030
echo.delay(message='Hello World!')
3131
```
@@ -56,10 +56,10 @@ from eb_sqs.decorators import task
5656

5757
@task(queue_name='test', max_retries=5)
5858
def upload_file(message):
59-
print '# of retries: {}'.format(upload_file.retry_num)
59+
print('# of retries: {}'.format(upload_file.retry_num))
6060
try:
6161
# upload ...
62-
expect ConnectionException:
62+
except ConnectionException:
6363
upload_file.retry()
6464
```
6565

@@ -69,7 +69,7 @@ The retry call supports the `delay` and `execute_inline` arguments in order to d
6969

7070
#### Executing Tasks
7171

72-
The Elastic Beanstalk Worker Tier sends all tasks to a API endpoint. django-eb-sqs has already such an endpoint which can be used by specifing the url mapping in your `urls.py` file.
72+
The Elastic Beanstalk Worker Tier sends all tasks to a API endpoint. django-eb-sqs has already such an endpoint which can be used by specifying the url mapping in your `urls.py` file.
7373

7474
```python
7575
urlpatterns = [
@@ -114,7 +114,7 @@ python manage.py process_queue --queues queue1,prefix:pr1-,queue2 # process queu
114114
```
115115

116116
#### Group Tasks
117-
Multiple tasks can be grouped by specifing the `group_id` argument when calling `delay` on a task.
117+
Multiple tasks can be grouped by specifying the `group_id` argument when calling `delay` on a task.
118118
If all tasks of a specific group are executed then the group callback task specified by `EB_SQS_GROUP_CALLBACK_TASK` is executed.
119119

120120
Example calls:
@@ -141,6 +141,8 @@ The following settings can be used to fine tune django-eb-sqs. Copy them into yo
141141
- EB_SQS_MAX_NUMBER_OF_MESSAGES (`10`): The maximum number of messages to read in a single call from SQS (<= 10).
142142
- EB_SQS_WAIT_TIME_S (`2`): The time to wait (seconds) when receiving messages from SQS.
143143
- EB_SQS_AUTO_ADD_QUEUE (`False`): If queues should be added automatically to AWS if they don't exist.
144+
- EB_SQS_QUEUE_MESSAGE_RETENTION (`1209600`): The value (in seconds) to be passed to MessageRetentionPeriod parameter, when creating a queue (only relevant in case EB_SQS_AUTO_ADD_QUEUE is set to True).
145+
- EB_SQS_QUEUE_VISIBILITY_TIMEOUT (`300`): The value (in seconds) to be passed to VisibilityTimeout parameter, when creating a queue (only relevant in case EB_SQS_AUTO_ADD_QUEUE is set to True).
144146
- EB_SQS_DEAD_LETTER_MODE (`False`): Enable if this worker is handling the SQS dead letter queue. Tasks won't be executed but group callback is.
145147
- EB_SQS_DEFAULT_DELAY (`0`): Default task delay time in seconds.
146148
- EB_SQS_DEFAULT_MAX_RETRIES (`0`): Default retry limit for all tasks.

eb_sqs/aws/sqs_queue_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def _add_sqs_queue(self, queue_name):
4545
queue = self.sqs.create_queue(
4646
QueueName=queue_name,
4747
Attributes={
48-
'MessageRetentionPeriod': '1209600',
49-
'VisibilityTimeout': '300'
48+
'MessageRetentionPeriod': settings.QUEUE_MESSAGE_RETENTION,
49+
'VisibilityTimeout': settings.QUEUE_VISIBILITY_TIMEOUT
5050
}
5151
)
5252
self.queue_cache[queue_name] = queue

eb_sqs/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@
3434
AWS_MAX_RETRIES = getattr(settings, 'EB_SQS_AWS_MAX_RETRIES', 30) # type: int
3535

3636
REFRESH_PREFIX_QUEUES_S = getattr(settings, 'EB_SQS_REFRESH_PREFIX_QUEUES_S', 10) # type: int
37+
38+
QUEUE_MESSAGE_RETENTION = getattr(settings, 'EB_SQS_QUEUE_MESSAGE_RETENTION', '1209600') # type: str
39+
QUEUE_VISIBILITY_TIMEOUT = getattr(settings, 'EB_SQS_QUEUE_VISIBILITY_TIMEOUT', '300') # type: str

0 commit comments

Comments
 (0)