Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,25 @@ This README!
- When the bot is been running and you put your PC to sleep, the async worker will bug out
and intermittently crash the UI.
- The Settings screen save functionality is currently disabled.

### urllib pool connection errors

When running a larger number of bots within one FTUI instance, you may see urllib/requests
warnings about the pool connections being exhausted:

`connection pool is full, discarding connection: 127.0.0.1. Connection pools size: 10`

Raising the pool size limits can help avoid these warnings.

There are two command line/yaml config options that can be adjusted:

#### CLI

`ftui -c config.json --pool_connections 20 --pool_maxsize 15`

#### YAML config

```yaml
pool_connections: 20
pool_maxsize: 15
```
4 changes: 4 additions & 0 deletions example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ servers:
port : 8080

debug: False

# only uncomment these options if you are receiving urllib warnings about connection pool full
# pool_connections: 30
# pool_maxsize: 20
18 changes: 17 additions & 1 deletion ftui/ftui.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ def setup(args):

print(__doc__)

pool_connections = 20
if args.pool_connections:
pool_connections = args.pool_connections

pool_maxsize = 10
if args.pool_maxsize:
pool_maxsize = args.pool_maxsize

if args.yaml:
for s in args.servers:
try:
Expand All @@ -411,6 +419,8 @@ def setup(args):
username=s["username"],
password=s["password"],
config_path=config,
pool_connections=pool_connections,
pool_maxsize=pool_maxsize,
)

client_dict[ftui_client.name] = ftui_client
Expand All @@ -419,7 +429,11 @@ def setup(args):
else:
if config is not None:
try:
ftui_client = ftuic.FTUIClient(config_path=config)
ftui_client = ftuic.FTUIClient(
config_path=config,
pool_connections=pool_connections,
pool_maxsize=pool_maxsize,
)
client_dict[ftui_client.name] = ftui_client
except Exception as e:
raise RuntimeError("Cannot create freqtrade client") from e
Expand All @@ -439,6 +453,8 @@ def main():
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose debugging mode")

parser.add_argument("-c", "--config", nargs="?", help="Config to parse")
parser.add_argument("--pool_connections", nargs="?", default=20, help="Number of pool connections")
parser.add_argument("--pool_maxsize", nargs="?", default=10, help="Pool cache maxsize")

parser.add_argument(
"-y", "--yaml", nargs="?", help="Supply a YAML file instead of command line arguments."
Expand Down
10 changes: 9 additions & 1 deletion ftui/ftui_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(
password: Optional[str] = None,
*,
config_path=None,
pool_connections=20,
pool_maxsize=10,
):
self.name = name
self.url = url
Expand All @@ -37,6 +39,8 @@ def __init__(
self.config_path = config_path
self.rest_client = None
self.config = None
self.pool_connections = pool_connections
self.pool_maxsize = pool_maxsize

self.prev_closed_trade_count = 0
self.all_closed_trades = []
Expand Down Expand Up @@ -65,7 +69,11 @@ def setup_client(self):

server_url = f"http://{self.url}:{self.port}"

client = ftrc.FtRestClient(server_url, self.username, self.password)
client = ftrc.FtRestClient(server_url,
self.username,
self.password,
pool_connections=self.pool_connections,
pool_maxsize=self.pool_maxsize)

if client is not None:
c = client.version()
Expand Down