hummingbot: Autostart [source build] - fail with AttributeError: 'StdoutProxy' object has no attribute 'isatty'

Describe the bug When using the autostart script for source build specified in the documentation page. The script failed with the following error::

Traceback (most recent call last):
  File "bin/hummingbot_quickstart.py", line 144, in <module>
    main()
  File "bin/hummingbot_quickstart.py", line 140, in main
    asyncio.get_event_loop().run_until_complete(quick_start(args))
  File "/home/hummingbot/miniconda3/envs/hummingbot/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "bin/hummingbot_quickstart.py", line 119, in quick_start
    await safe_gather(*tasks)
  File "/home/hummingbot/hummingbot/core/utils/async_utils.py", line 22, in safe_gather
    return await asyncio.gather(*args, **kwargs)
  File "/home/hummingbot/hummingbot/client/hummingbot_application.py", line 214, in run
    await self.app.run()
  File "/home/hummingbot/hummingbot/client/ui/hummingbot_cli.py", line 72, in run
    self.app = Application(layout=self.layout, full_screen=True, key_bindings=self.bindings, style=load_style(),
  File "/home/hummingbot/miniconda3/envs/hummingbot/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 265, in __init__
    self.output = output or session.output
  File "/home/hummingbot/miniconda3/envs/hummingbot/lib/python3.8/site-packages/prompt_toolkit/application/current.py", line 65, in output
    self._output = create_output()
  File "/home/hummingbot/miniconda3/envs/hummingbot/lib/python3.8/site-packages/prompt_toolkit/output/defaults.py", line 38, in create_output
    if io.isatty():
AttributeError: 'StdoutProxy' object has no attribute 'isatty'

Note: script work when password is remove bin/hummingbot_quickstart.py -f CONFIG_FILE_NAME Steps To Reproduce

Here are the steps to reproduce the issue (see attachments in the section below):

  1. Install and run Hummingbot via source
  2. Connect your API key
  3. Create a strategy and use the exchange with API key connected and confirmed
  4. Exit instance
  5. Run autostart script : bin/hummingbot_quickstart.py -f CONFIG_FILE_NAME -p CONFIG_PASSWORD

Screenshots image

Release version 0.44.0 Attachments // Please attach your config file and log file to help us debug. It would be difficult for us to help you without those!

WARNING: Do NOT publish any exchange API keys or your wallet’s private key. Whoever has access to them may steal your assets!

Optional: your discord username:

┆Issue is synchronized with this Clickup task by Unito

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

This is a result of this change to hummingbot_cli.py.

Prior to this change, Application was instantiated when sys.stdout hadn’t been wrapped yet, during __init__. From the call stack, you can see how it gets to defaults.py, grabs sys.stdout, and calls isatty on it. Now that it’s called in run() sys.stdout is actually already hummingbot.client.ui.stdout_redirection.StdoutProxy.

I’d guess stdout_redirection.py was cargo-culted, or at least partly inspired, from prompt-toolkit’s patch_stdout.py and the updates adding isatty, fileno and encoding would be sufficient to fix this…

… However once past that I found we’ll run into a byte array vs string issue when vt100 calls the write method, as outlined in this still outstanding issue in prompt-toolkit.

Like the author of that diagnosis, I’d gone far enough down the rabbit hole at that point. Reverting the change to hummingbot_cli.py was the simplest solution for my use case.