Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

93
Vistas
Pubnub always times out in Django app

I'm building a Django app to listen to a Pubnub feed and store the messages in a database. I create a pubnub listener in my app's apps.py's AppConfig's ready() method.

Upon launching my app on Heroku, I get the really unhelpful error

2017-04-26T02:17:50.038060+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 30 seconds of SIGTERM
2017-04-26T02:17:50.038060+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2017-04-26T02:17:50.134619+00:00 heroku[web.1]: Process exited with status 137

I suspect django wants to clean up the AppConfig process and is getting upset that there is a pubnub object hanging around in there. Is that the problem? How do I fix it?

I also see that (at least implicitly by example) Heroku recommends using the twisted interface. Is it bad that I'm not?

Here's the relevant code:

I created a mypubnub.py based on Pubnub's hello world example:

from pubnub.pubnub import PubNub
from pubnub.pnconfiguration import PNConfiguration
from pubnub.callbacks import SubscribeCallback


class MySubscribeCallback(SubscribeCallback):
    def presence(self, pubnub, presence):
        pass

    def status(self, pubnub, status):
        pass

    def message(self, pubnub, message):
        pass  # I'll actually do the storage here later


def create_pubnub():
    pnconf = PNConfiguration()
    pnconf.subscribe_key = 'sub-c-blargyblargblarg'
    pnconf.publish_key = 'pub-c-blargyblargblarg'
    pubnub = PubNub(pnconf)

    pubnub.add_listener(MySubscribeCallback())
    pubnub.subscribe().channels('achannel').execute()

    return pubnub

I instantiate that pubnub stuff in apps.pyfrom django.apps import AppConfig

from .mypubnub import create_pubnub

class MyAppConfig(AppConfig):
    name = 'myapp'

    def ready(self):
        pn = create_pubnub()
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Subscribing from Server is the Exception

While it is something that some PubNub customers do successfully, subscribing from your server side is typically the exception rather than the rule. It does have its proper use case though.

In this case, best practice would be to use PubNub BLOCKS to POST each message that is published from within the PubNub Network to your server rather than have your server listen on a channel or every channel to do the same.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda