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

208
Vistas
Python threading timer initial daemon

This code is not working......

self._thread = threading.Timer(interval=2, 
                               function=self._sendRequestState, 
                               args=(self._lockState,), 
                               daemon=True).start()

So I should write down like this..

self._thread = threading.Timer(interval=2, 
                               function=self._sendRequestState, 
                               args=(self._lockState,))
self._thread.daemon = True
self._thread.start()

But the Timer class has Thread.__init__, Thread.__init__ has "daemon" for input parameter. I don't have any idea why it doesn't work...

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can find the source code of that threading.Thread() constructor here (of cpython, the most common python implementation):

def __init__(self, interval, function, args=None, kwargs=None):
    Thread.__init__(self)
    self.interval = interval
    self.function = function
    self.args = args if args is not None else []
    self.kwargs = kwargs if kwargs is not None else {}
    self.finished = Event()

If you pass daemon=True into it, that will be put in kwargs, but as you can see in the code, nothing happens with it. So yes, you're correct, you'll have to set the daemon attribute after creating it (and before calling start(). There seems to be no option to set it directly when constructing the Timer.

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