Skip to content

Conversation

@MarsYoung
Copy link
Contributor

get_active_containers is blocking every request, make a single request a long response time.

this sync function will block every request 
now I fix it
@MarsYoung
Copy link
Contributor Author

@fengtality @cardosofede @tomasgaudino @rapcmia
Could you please review this PR? It fixes a blocking issue in get_active_containers.

Copy link
Contributor

@cardosofede cardosofede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls test that works @rapcmia btw i think that we should evaluate doing it async by default

@rapcmia
Copy link
Contributor

rapcmia commented Mar 14, 2025

Could you please review this PR? It fixes a blocking issue in get_active_containers.

Pls test that works @rapcmia btw i think that we should evaluate doing it async by default

I have a look later this afternoon 🙏🏼

@rapcmia rapcmia self-requested a review March 14, 2025 03:28
@rapcmia rapcmia moved this to Under Review in Pull Request Board Mar 14, 2025
@rapcmia
Copy link
Contributor

rapcmia commented Mar 14, 2025

PR update:

  • Setup this PR on linux (ubuntu24.04) using source build for both dashboard and docker for broker (emqx)
  • Setup successful and able to launch hummingbot-deploy ✅
    • Successfully add credentials, upload controller-config (pmm_simple) then deploy ✅
  • Observed error on backend-api logs
    image
    INFO:     Waiting for application startup.                                                                                                                    
    2025-03-14 20:19:28,243 - asyncio - ERROR - Task exception was never retrieved                                                                                
    future: <Task finished name='Task-14' coro=<BotsManager.update_active_bots() done, defined at /home/yawnyunehh/hummingbot/backend-api/59/services/bots_orchest
    rator.py:88> exception=TypeError("'coroutine' object is not iterable")>                                                                                       
    Traceback (most recent call last):                                                                                                                            
      File "/home/yawnyunehh/hummingbot/backend-api/59/services/bots_orchestrator.py", line 97, in update_active_bots                                             
        for bot in active_hbot_containers:                                                                                                                        
    TypeError: 'coroutine' object is not iterable                                                                                                                 
    /home/yawnyunehh/miniconda3/envs/backend-api/lib/python3.10/asyncio/runners.py:44: RuntimeWarning: coroutine 'BotsManager.get_active_containers' was never awa
    ited                                                                                                                                                          
      return loop.run_until_complete(main)                                                                                                                        
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
    

Test when no container active

  • Deployed an instance with pmm simple controller on kucoin, no instance available even tho a container has been running for 4mins already. Orders are placed and cancelled
    image

Steps to reproduce:

  1. Setup source build for this PR and dashboard
  2. Clone deploy then docker compose -up emqx for broker
  3. After successfully uploaded a config, deploy an instance and observe backend-api logs
    • Make sure "POST /create-hummingbot-instance HTTP/1.1" is 200 ok
    • Observe deploy page and refresh if instance is created/active
    • Relaunc backend-api and check again
    • On terminal, run docker ps to check active containers
  4. Observed that on instance page, no container is active ❌

fix  returns a coroutine for the active containers
Copy link
Contributor Author

@MarsYoung MarsYoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add await to sovle returns a coroutine for active containers

@MarsYoung
Copy link
Contributor Author

PR update:

  • Setup this PR on linux (ubuntu24.04) using source build for both dashboard and docker for broker (emqx)

  • Setup successful and able to launch hummingbot-deploy ✅

    • Successfully add credentials, upload controller-config (pmm_simple) then deploy ✅
  • Observed error on backend-api logs
    image

    INFO:     Waiting for application startup.                                                                                                                    
    2025-03-14 20:19:28,243 - asyncio - ERROR - Task exception was never retrieved                                                                                
    future: <Task finished name='Task-14' coro=<BotsManager.update_active_bots() done, defined at /home/yawnyunehh/hummingbot/backend-api/59/services/bots_orchest
    rator.py:88> exception=TypeError("'coroutine' object is not iterable")>                                                                                       
    Traceback (most recent call last):                                                                                                                            
      File "/home/yawnyunehh/hummingbot/backend-api/59/services/bots_orchestrator.py", line 97, in update_active_bots                                             
        for bot in active_hbot_containers:                                                                                                                        
    TypeError: 'coroutine' object is not iterable                                                                                                                 
    /home/yawnyunehh/miniconda3/envs/backend-api/lib/python3.10/asyncio/runners.py:44: RuntimeWarning: coroutine 'BotsManager.get_active_containers' was never awa
    ited                                                                                                                                                          
      return loop.run_until_complete(main)                                                                                                                        
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
    

Test when no container active

  • Deployed an instance with pmm simple controller on kucoin, no instance available even tho a container has been running for 4mins already. Orders are placed and cancelled
    image

Steps to reproduce:

  1. Setup source build for this PR and dashboard

  2. Clone deploy then docker compose -up emqx for broker

  3. After successfully uploaded a config, deploy an instance and observe backend-api logs

    • Make sure "POST /create-hummingbot-instance HTTP/1.1" is 200 ok
    • Observe deploy page and refresh if instance is created/active
    • Relaunc backend-api and check again
    • On terminal, run docker ps to check active containers
  4. Observed that on instance page, no container is active ❌

this result was caused by the missing of await keyword,fixed it @rapcmia

Copy link
Contributor

@rapcmia rapcmia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Setup this PR with latest dashboard and deploy(broker) on source
  • Build docker image for tests ✅
  • Reported issues has been fixed by developer ✅
  • Add credentials and observe diff from development branch
    • Loads portfolio successfully

Test what happens when there are no containers?

  • All ok, Launched 2 instances
  • Relaunch backend-api and dashboard
    • 1 instance paused and other is active ✅
    • Start the instance and worked ok, 2 instance actively fetched from backend-api and dashboard/instance page

Testing with a mix of running and stopped containers

  • Pause an instance while another is running then relaunch backend-api ✅
  • Start an instance while another is paused observed behavior after backend api is launched ✅
  • Paused all instance, relaunch backend-api then start all instance again ✅
  • Archived all bots at the same time and observe behavior ✅

Run same tests cases with docker build ✅

@rapcmia rapcmia merged commit ac60a14 into hummingbot:main Mar 18, 2025
@rapcmia rapcmia moved this from Under Review to Development 2.5.0 in Pull Request Board Mar 18, 2025
@rapcmia rapcmia moved this from Staging 2.5.0 to Release 2.4.0 in Pull Request Board Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants