koval01 / telegram-me

A convenient API to get a channel from t.me in json
https://tme.koval.page
GNU General Public License v3.0
3 stars 2 forks source link

docker run error #53

Open dengchangdong opened 6 days ago

dengchangdong commented 6 days ago

Telegram-to-API | INFO: Started server process [6] Telegram-to-API | INFO: Waiting for application startup. Telegram-to-API | INFO: Application startup complete. Telegram-to-API | Aborted (core dumped)

koval01 commented 5 days ago
image

The problem is most likely in your system. The image itself plays normally.

dengchangdong commented 2 days ago

System info:

Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-4-amd64
Architecture: x86-64
Docker version 19.03.15, build 99e3ed8919

Docker logs:

Telegram-to-API  | RuntimeError: can't start new thread
Telegram-to-API  | INFO:     Waiting for child process [5788]
Telegram-to-API  | INFO:     Child process [5788] died
Telegram-to-API  | INFO:     Waiting for child process [5789]
Telegram-to-API  | INFO:     Child process [5789] died
Telegram-to-API  | INFO:     Waiting for child process [5790]
Telegram-to-API  | INFO:     Child process [5790] died
Telegram-to-API  | INFO:     Waiting for child process [5791]
Telegram-to-API  | INFO:     Child process [5791] died
Telegram-to-API  | INFO:     Waiting for child process [5792]
Telegram-to-API  | INFO:     Child process [5792] died
Telegram-to-API  | Process SpawnProcess-4627:
Telegram-to-API  | Traceback (most recent call last):
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
Telegram-to-API  |     self.run()
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 108, in run
Telegram-to-API  |     self._target(*self._args, **self._kwargs)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
Telegram-to-API  |     target(sockets=sockets)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/supervisors/multiprocess.py", line 62, in target
Telegram-to-API  |     threading.Thread(target=self.always_pong, daemon=True).start()
Telegram-to-API  |   File "/usr/local/lib/python3.12/threading.py", line 994, in start
Telegram-to-API  |     _start_new_thread(self._bootstrap, ())
Telegram-to-API  | RuntimeError: can't start new thread
Telegram-to-API  | Process SpawnProcess-4629:
Telegram-to-API  | Traceback (most recent call last):
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
Telegram-to-API  |     self.run()
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 108, in run
Telegram-to-API  |     self._target(*self._args, **self._kwargs)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
Telegram-to-API  |     target(sockets=sockets)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/supervisors/multiprocess.py", line 62, in target
Telegram-to-API  |     threading.Thread(target=self.always_pong, daemon=True).start()
Telegram-to-API  |   File "/usr/local/lib/python3.12/threading.py", line 994, in start
Telegram-to-API  |     _start_new_thread(self._bootstrap, ())
Telegram-to-API  | RuntimeError: can't start new thread
Telegram-to-API  | Process SpawnProcess-4628:
Telegram-to-API  | Traceback (most recent call last):
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
Telegram-to-API  |     self.run()
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 108, in run
Telegram-to-API  |     self._target(*self._args, **self._kwargs)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
Telegram-to-API  |     target(sockets=sockets)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/supervisors/multiprocess.py", line 62, in target
Telegram-to-API  |     threading.Thread(target=self.always_pong, daemon=True).start()
Telegram-to-API  |   File "/usr/local/lib/python3.12/threading.py", line 994, in start
Telegram-to-API  |     _start_new_thread(self._bootstrap, ())
Telegram-to-API  | RuntimeError: can't start new thread
Telegram-to-API  | Process SpawnProcess-4626:
Telegram-to-API  | Traceback (most recent call last):
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
Telegram-to-API  |     self.run()
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 108, in run
Telegram-to-API  |     self._target(*self._args, **self._kwargs)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
Telegram-to-API  |     target(sockets=sockets)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/supervisors/multiprocess.py", line 62, in target
Telegram-to-API  |     threading.Thread(target=self.always_pong, daemon=True).start()
Telegram-to-API  |   File "/usr/local/lib/python3.12/threading.py", line 994, in start
Telegram-to-API  |     _start_new_thread(self._bootstrap, ())
Telegram-to-API  | RuntimeError: can't start new thread
Telegram-to-API  | Process SpawnProcess-4630:
Telegram-to-API  | Traceback (most recent call last):
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
Telegram-to-API  |     self.run()
Telegram-to-API  |   File "/usr/local/lib/python3.12/multiprocessing/process.py", line 108, in run
Telegram-to-API  |     self._target(*self._args, **self._kwargs)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 80, in subprocess_started
Telegram-to-API  |     target(sockets=sockets)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/supervisors/multiprocess.py", line 62, in target
Telegram-to-API  |     threading.Thread(target=self.always_pong, daemon=True).start()
Telegram-to-API  |   File "/usr/local/lib/python3.12/threading.py", line 994, in start
Telegram-to-API  |     _start_new_thread(self._bootstrap, ())

Thanks!

koval01 commented 2 days ago

Perhaps you are running an application on shared hosting, something like heroku. The system shows that the server processor has a dozen or several dozen cores, causing the application to try to run the appropriate number of vorkers. The solution to this can be to modify the image, for example use different parameters in start.sh or dockerfile. You can also deploy the application natively without using docker, in which case just use a command like this './start.sh 3' and you can adjust the number of wokers. I also updated the repository a bit to make it easier to deploy the app, and I just tested the app deploy on render.com, all I had to specify for the deploy was a link to that repository (for the docker version). I hope everything works out for you and you can solve the launch issues.

dengchangdong commented 11 hours ago

Thanks Koval! The operating environment is bandwagonhost's vps. I modified the code of start.sh according to the prompt of chatgpt, and it worked normally after being packaged into docker. The following is the code of start.sh:

#!/bin/bash

# Set the default port if not defined
PORT=${PORT:-8000}

# Run the Hypercorn server
UVICORN_CMD="uvicorn app.main:app --host=0.0.0.0 --port=$PORT --workers=1 --loop asyncio"

# Execute the command
$UVICORN_CMD

But when accessing http://localhost:8080/v1/preview/durov, the server returns a 500 error, and the docker log is as follows:

Telegram-to-API  | INFO:     Started server process [7]
Telegram-to-API  | INFO:     Waiting for application startup.
Telegram-to-API  | INFO:     Application startup complete.
Telegram-to-API  | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
Telegram-to-API  | INFO:     110.184.32.121:21376 - "GET /v1/preview/durov HTTP/1.1" 500 Internal Server Error
Telegram-to-API  | ERROR:    Exception in ASGI application
Telegram-to-API  |   + Exception Group Traceback (most recent call last):
Telegram-to-API  |   |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 77, in collapse_excgroups
Telegram-to-API  |   |     yield
Telegram-to-API  |   |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 186, in __call__
Telegram-to-API  |   |     async with anyio.create_task_group() as task_group:
Telegram-to-API  |   |                ^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   |   File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 736, in __aexit__
Telegram-to-API  |   |     raise BaseExceptionGroup(
Telegram-to-API  |   | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
Telegram-to-API  |   +-+---------------- 1 ----------------
Telegram-to-API  |     | Traceback (most recent call last):
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
Telegram-to-API  |     |     result = await app(  # type: ignore[func-returns-value]
Telegram-to-API  |     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
Telegram-to-API  |     |     return await self.app(scope, receive, send)
Telegram-to-API  |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
Telegram-to-API  |     |     await super().__call__(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
Telegram-to-API  |     |     await self.middleware_stack(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__
Telegram-to-API  |     |     raise exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
Telegram-to-API  |     |     await self.app(scope, receive, _send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
Telegram-to-API  |     |     with collapse_excgroups():
Telegram-to-API  |     |          ^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
Telegram-to-API  |     |     self.gen.throw(value)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
Telegram-to-API  |     |     raise exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 187, in __call__
Telegram-to-API  |     |     response = await self.dispatch_func(request, call_next)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/code/app/middleware/cache_header.py", line 41, in dispatch
Telegram-to-API  |     |     response = await call_next(request)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 163, in call_next
Telegram-to-API  |     |     raise app_exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 149, in coro
Telegram-to-API  |     |     await self.app(scope, receive_or_disconnect, send_no_error)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
Telegram-to-API  |     |     with collapse_excgroups():
Telegram-to-API  |     |          ^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
Telegram-to-API  |     |     self.gen.throw(value)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
Telegram-to-API  |     |     raise exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 187, in __call__
Telegram-to-API  |     |     response = await self.dispatch_func(request, call_next)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/code/app/middleware/process_time.py", line 35, in dispatch
Telegram-to-API  |     |     response = await call_next(request)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 163, in call_next
Telegram-to-API  |     |     raise app_exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 149, in coro
Telegram-to-API  |     |     await self.app(scope, receive_or_disconnect, send_no_error)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
Telegram-to-API  |     |     with collapse_excgroups():
Telegram-to-API  |     |          ^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
Telegram-to-API  |     |     self.gen.throw(value)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
Telegram-to-API  |     |     raise exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 187, in __call__
Telegram-to-API  |     |     response = await self.dispatch_func(request, call_next)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/code/app/middleware/node.py", line 33, in dispatch
Telegram-to-API  |     |     response = await call_next(request)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 163, in call_next
Telegram-to-API  |     |     raise app_exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 149, in coro
Telegram-to-API  |     |     await self.app(scope, receive_or_disconnect, send_no_error)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/cors.py", line 85, in __call__
Telegram-to-API  |     |     await self.app(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
Telegram-to-API  |     |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
Telegram-to-API  |     |     raise exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
Telegram-to-API  |     |     await app(scope, receive, sender)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
Telegram-to-API  |     |     await self.middleware_stack(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
Telegram-to-API  |     |     await route.handle(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
Telegram-to-API  |     |     await self.app(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
Telegram-to-API  |     |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
Telegram-to-API  |     |     raise exc
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
Telegram-to-API  |     |     await app(scope, receive, sender)
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 73, in app
Telegram-to-API  |     |     response = await f(request)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 278, in app
Telegram-to-API  |     |     raw_response = await run_endpoint_function(
Telegram-to-API  |     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
Telegram-to-API  |     |     return await dependant.call(**values)
Telegram-to-API  |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/code/app/routes/v1/preview.py", line 26, in preview
Telegram-to-API  |     |     result = await Telegram().preview(channel)
Telegram-to-API  |     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/code/app/telegram/telegram.py", line 101, in preview
Telegram-to-API  |     |     response = await Request().preview(channel)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/code/app/telegram/request.py", line 158, in preview
Telegram-to-API  |     |     response = await self.__request(channel)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/code/app/telegram/request.py", line 52, in __request
Telegram-to-API  |     |     async with session.request(
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1353, in __aenter__
Telegram-to-API  |     |     self._resp = await self._coro
Telegram-to-API  |     |                  ^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request
Telegram-to-API  |     |     conn = await self._connector.connect(
Telegram-to-API  |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect
Telegram-to-API  |     |     proto = await self._create_connection(req, traces, timeout)
Telegram-to-API  |     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 975, in _create_connection
Telegram-to-API  |     |     _, proto = await self._create_direct_connection(req, traces, timeout)
Telegram-to-API  |     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1285, in _create_direct_connection
Telegram-to-API  |     |     sslcontext = await self._get_ssl_context(req)
Telegram-to-API  |     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1028, in _get_ssl_context
Telegram-to-API  |     |     return await self._make_or_get_ssl_context(True)
Telegram-to-API  |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1039, in _make_or_get_ssl_context
Telegram-to-API  |     |     result = await loop.run_in_executor(
Telegram-to-API  |     |                    ^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 863, in run_in_executor
Telegram-to-API  |     |     executor.submit(func, *args), loop=self)
Telegram-to-API  |     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 179, in submit
Telegram-to-API  |     |     self._adjust_thread_count()
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 202, in _adjust_thread_count
Telegram-to-API  |     |     t.start()
Telegram-to-API  |     |   File "/usr/local/lib/python3.12/threading.py", line 994, in start
Telegram-to-API  |     |     _start_new_thread(self._bootstrap, ())
Telegram-to-API  |     | RuntimeError: can't start new thread
Telegram-to-API  |     +------------------------------------
Telegram-to-API  | 
Telegram-to-API  | During handling of the above exception, another exception occurred:
Telegram-to-API  | 
Telegram-to-API  | Traceback (most recent call last):
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
Telegram-to-API  |     result = await app(  # type: ignore[func-returns-value]
Telegram-to-API  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
Telegram-to-API  |     return await self.app(scope, receive, send)
Telegram-to-API  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
Telegram-to-API  |     await super().__call__(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/applications.py", line 113, in __call__
Telegram-to-API  |     await self.middleware_stack(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 187, in __call__
Telegram-to-API  |     raise exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/errors.py", line 165, in __call__
Telegram-to-API  |     await self.app(scope, receive, _send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
Telegram-to-API  |     with collapse_excgroups():
Telegram-to-API  |          ^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
Telegram-to-API  |     self.gen.throw(value)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
Telegram-to-API  |     raise exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 187, in __call__
Telegram-to-API  |     response = await self.dispatch_func(request, call_next)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/code/app/middleware/cache_header.py", line 41, in dispatch
Telegram-to-API  |     response = await call_next(request)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 163, in call_next
Telegram-to-API  |     raise app_exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 149, in coro
Telegram-to-API  |     await self.app(scope, receive_or_disconnect, send_no_error)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
Telegram-to-API  |     with collapse_excgroups():
Telegram-to-API  |          ^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
Telegram-to-API  |     self.gen.throw(value)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
Telegram-to-API  |     raise exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 187, in __call__
Telegram-to-API  |     response = await self.dispatch_func(request, call_next)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/code/app/middleware/process_time.py", line 35, in dispatch
Telegram-to-API  |     response = await call_next(request)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 163, in call_next
Telegram-to-API  |     raise app_exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 149, in coro
Telegram-to-API  |     await self.app(scope, receive_or_disconnect, send_no_error)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 185, in __call__
Telegram-to-API  |     with collapse_excgroups():
Telegram-to-API  |          ^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/contextlib.py", line 158, in __exit__
Telegram-to-API  |     self.gen.throw(value)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/_utils.py", line 83, in collapse_excgroups
Telegram-to-API  |     raise exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 187, in __call__
Telegram-to-API  |     response = await self.dispatch_func(request, call_next)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/code/app/middleware/node.py", line 33, in dispatch
Telegram-to-API  |     response = await call_next(request)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 163, in call_next
Telegram-to-API  |     raise app_exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 149, in coro
Telegram-to-API  |     await self.app(scope, receive_or_disconnect, send_no_error)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/cors.py", line 85, in __call__
Telegram-to-API  |     await self.app(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
Telegram-to-API  |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
Telegram-to-API  |     raise exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
Telegram-to-API  |     await app(scope, receive, sender)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 715, in __call__
Telegram-to-API  |     await self.middleware_stack(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
Telegram-to-API  |     await route.handle(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 288, in handle
Telegram-to-API  |     await self.app(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 76, in app
Telegram-to-API  |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
Telegram-to-API  |     raise exc
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
Telegram-to-API  |     await app(scope, receive, sender)
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 73, in app
Telegram-to-API  |     response = await f(request)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 278, in app
Telegram-to-API  |     raw_response = await run_endpoint_function(
Telegram-to-API  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
Telegram-to-API  |     return await dependant.call(**values)
Telegram-to-API  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/code/app/routes/v1/preview.py", line 26, in preview
Telegram-to-API  |     result = await Telegram().preview(channel)
Telegram-to-API  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/code/app/telegram/telegram.py", line 101, in preview
Telegram-to-API  |     response = await Request().preview(channel)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/code/app/telegram/request.py", line 158, in preview
Telegram-to-API  |     response = await self.__request(channel)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/code/app/telegram/request.py", line 52, in __request
Telegram-to-API  |     async with session.request(
Telegram-to-API  |                ^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1353, in __aenter__
Telegram-to-API  |     self._resp = await self._coro
Telegram-to-API  |                  ^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request
Telegram-to-API  |     conn = await self._connector.connect(
Telegram-to-API  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect
Telegram-to-API  |     proto = await self._create_connection(req, traces, timeout)
Telegram-to-API  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 975, in _create_connection
Telegram-to-API  |     _, proto = await self._create_direct_connection(req, traces, timeout)
Telegram-to-API  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1285, in _create_direct_connection
Telegram-to-API  |     sslcontext = await self._get_ssl_context(req)
Telegram-to-API  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1028, in _get_ssl_context
Telegram-to-API  |     return await self._make_or_get_ssl_context(True)
Telegram-to-API  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1039, in _make_or_get_ssl_context
Telegram-to-API  |     result = await loop.run_in_executor(
Telegram-to-API  |                    ^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 863, in run_in_executor
Telegram-to-API  |     executor.submit(func, *args), loop=self)
Telegram-to-API  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Telegram-to-API  |   File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 179, in submit
Telegram-to-API  |     self._adjust_thread_count()
Telegram-to-API  |   File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 202, in _adjust_thread_count
Telegram-to-API  |     t.start()
Telegram-to-API  |   File "/usr/local/lib/python3.12/threading.py", line 994, in start
Telegram-to-API  |     _start_new_thread(self._bootstrap, ())
Telegram-to-API  | RuntimeError: can't start new thread
koval01 commented 5 hours ago

The issue you're facing is that the application is trying to create more threads than the system can handle, leading to the error: "RuntimeError: can't start new thread". This error indicates that the system cannot create any more threads.

Please make sure you’re running a reasonable number of workers. If you're using a VPS with only 1 CPU core, you shouldn't run more than 3 workers. In fact, I recommend setting the number of workers to just 1 for testing purposes. You can do this by running the following command:

uvicorn app.main:app --workers 1 --host=0.0.0.0 --port=8000

This should help reduce the load on your system and prevent the thread limit from being exceeded. Try to use exactly this minimalistic command, without any third-party settings, let them remain default.