1

I'm using boto and SNS to send push notifications to iOS. I've made a wrapper class, APNS, that keeps a long running boto.SNSConnection as a member variable.

I'd like to have an instance of the APNS class as a global variable, so I can use celery to send push notifications in the background.

Are there any problems with keeping a long running SNSConnection and re-using it, or should I be creating a new connection every time I want to publish a message?

Dr. Acula
  • 2,392
  • 4
  • 17
  • 17
  • I haven't worked with SNS but I use long running connections for SQS and S3 for days and haven't had any issue, you might want a process monitor to check if process is down and rerun it, that way my processes run for months at a time. – PepperoniPizza Sep 05 '13 at 23:23

2 Answers2

1

You should be reusing the SNS connection for best performance. That said, please ensure that you detect and re-establish the connection if it is closed.

Rohan Deshpande
  • 3,535
  • 1
  • 26
  • 31
0

Looking at the signature of the SNSConnection, There is no timeout parameter so my guess there is no problem using a long term connection.

class SNSConnection(AWSQueryConnection):
    """
    Amazon Simple Notification Service
    """


      def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
                 is_secure=True, port=None, proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 security_token=None, validate_certs=True,
                 profile_name=None):
Amit Talmor
  • 7,174
  • 4
  • 25
  • 29