question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeError: can't start new thread

See original GitHub issue

Describe the bug: We’re getting errors “RuntimeError: can’t start new thread”. The only change we’ve introduced is turning Elastic on. Since than we’re getting these errors. When running long enough, this exhausts the thread pool on the server.

To Reproduce

  1. Use APM with Django

Expected behavior: To not run out of threads.

Environment (please complete the following information)

  • OS: Ubuntu 16.04.5 LTS
  • Python version: 3.5.2
  • Framework and version [e.g. Django 2.1]: Django 1.11.20
  • APM Server version: elastic cloud
  • Agent version: elastic-apm 4.2.1

Additional context

RuntimeError: can’t start new thread File “threading.py”, line 1180, in run self.function(*self.args, **self.kwargs) File “elasticapm/transport/base.py”, line 124, in flush self._start_flush_timer() File “elasticapm/transport/base.py”, line 160, in _start_flush_timer self._flush_timer.start() File “threading.py”, line 844, in start _start_new_thread(self._bootstrap, ())

We’re running with celery and sentry.

  • Agent config options

    Click to expand
    if env('ELASTIC_APM'):
    ELASTIC_APM = {
        # Set required service name. Allowed characters:
        # a-z, A-Z, 0-9, -, _, and space
        'SERVICE_NAME': 'CLIENT PRODUCTION',
        # Use if APM Server requires a token
        'SECRET_TOKEN': env('ELASTIC_APM_SECRET_TOKEN'),
        # Set custom APM Server URL (default: http://localhost:8200)
        'SERVER_URL': env('ELASTIC_APM_SERVER_URL)
    }
    
    INSTALLED_APPS += ('elasticapm.contrib.django',)
    # The Elastic APM tracing middleware needs to be first.
    MIDDLEWARE_CLASSES = (
        'elasticapm.contrib.django.middleware.TracingMiddleware',
        ) + MIDDLEWARE_CLASSES
    

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
beniwohlicommented, Apr 9, 2019

I plan to do a release tomorrow 😃

0reactions
Kalanamithcommented, Jan 22, 2020

Issue still existst

/site-packages/elasticapm/metrics/base_metrics.py:104: in _start_collect_timer
    self._collect_timer.start()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <IntervalTimer(eapm metrics collect timer, initial daemon)>

    def start(self):
        """Start the thread's activity.
    
        It must be called at most once per thread object. It arranges for the
        object's run() method to be invoked in a separate thread of control.
    
        This method will raise a RuntimeError if called more than once on the
        same thread object.
    
        """
        if not self._initialized:
            raise RuntimeError("thread.__init__() not called")
    
        if self._started.is_set():
            raise RuntimeError("threads can only be started once")
        with _active_limbo_lock:
            _limbo[self] = self
        try:
>           _start_new_thread(self._bootstrap, ())
E           RuntimeError: can't start new thread
Read more comments on GitHub >

github_iconTop Results From Across the Web

error: can't start new thread - Stack Overflow
The "can't start new thread" error almost certainly due to the fact that you have already have too many threads running within your...
Read more >
RuntimeError: can't start new thread - Super User
I'm running into an issue where running multiple instances of the same Python program on my server is causing some of the jobs...
Read more >
Python flask - RuntimeError: can't start new thread : Forums
Python flask - RuntimeError: can't start new thread. Hello, after 2/3 hours that my script works normally, i get this kind of error....
Read more >
RuntimeError: can't start new thread (0.23.2) #311 - GitHub
Long story short operator pod gets killed due to hitting thread limit reached as process keeps on spawning new threads and in loads ......
Read more >
Runtime Error: Cant't start new thread : r/Heroku - Reddit
Runtime Error : Cant't start new thread. Im trying to extract stock information from of all the companies in the s&p 500 using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found