From a59cf9b9aa3c1f848072cba2b430801a4da9c3ee Mon Sep 17 00:00:00 2001
From: shortcutme <tamas@zeronet.io>
Date: Sun, 19 Feb 2017 13:20:49 +0100
Subject: [PATCH] Rev1930, Change stack size argument for special hardwares

---
 src/Config.py | 3 ++-
 src/main.py   | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/Config.py b/src/Config.py
index 765c8482..3a04c7b1 100644
--- a/src/Config.py
+++ b/src/Config.py
@@ -10,7 +10,7 @@ class Config(object):
 
     def __init__(self, argv):
         self.version = "0.5.2"
-        self.rev = 1929
+        self.rev = 1930
         self.argv = argv
         self.action = None
         self.config_file = "zeronet.conf"
@@ -202,6 +202,7 @@ class Config(object):
         self.parser.add_argument('--keep_ssl_cert', help='Disable new SSL cert generation on startup', action='store_true')
         self.parser.add_argument('--max_files_opened', help='Change maximum opened files allowed by OS to this value on startup',
                                  default=2048, type=int, metavar='limit')
+        self.parser.add_argument('--stack_size', help='Change thread stack size', default=None, type=int, metavar='thread_stack_size')
         self.parser.add_argument('--use_tempfiles', help='Use temporary files when downloading (experimental)',
                                  type='bool', choices=[True, False], default=False)
         self.parser.add_argument('--stream_downloads', help='Stream download directly to files (experimental)',
diff --git a/src/main.py b/src/main.py
index cb62ba14..d0db50f7 100644
--- a/src/main.py
+++ b/src/main.py
@@ -107,6 +107,11 @@ config.parse()  # Parse again to add plugin configuration options
 # Log current config
 logging.debug("Config: %s" % config)
 
+# Modify stack size on special hardwares
+if config.stack_size:
+    import threading
+    threading.stack_size(config.stack_size)
+
 # Use pure-python implementation of msgpack to save CPU
 if config.msgpack_purepython:
     os.environ["MSGPACK_PUREPYTHON"] = "True"