Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add timeout setting

  • Loading branch information...
commit d94fa395623f78bd01dca590eb9848c5cc467c74 1 parent d729b63
Silas Sewell authored November 01, 2010

Showing 1 changed file with 25 additions and 3 deletions. Show diff stats Hide diff stats

  1. 28  funcshell/__init__.py
28  funcshell/__init__.py
@@ -26,6 +26,7 @@ def __init__(self):
26 26
         self.async = False
27 27
         self.threads = 1
28 28
         self.list = set()
  29
+        self.timeout = fc.DEFAULT_TIMEOUT
29 30
 
30 31
     def add(self, client_list):
31 32
         old_list_len = len(self.list)
@@ -45,10 +46,11 @@ def minions(self, clients_glob):
45 46
         return fc.Minions(clients_glob).get_all_hosts()
46 47
 
47 48
     def overlord(self):
  49
+        options = {'timeout': self.timeout}
48 50
         if self.async:
49  
-            self._overlord = fc.Overlord(self.join(), async=self.async, nforks=self.threads)
50  
-        else:
51  
-            self._overlord = fc.Overlord(self.join())
  51
+            options['async'] = self.async
  52
+            options['nforks'] = self.threads
  53
+        self._overlord = fc.Overlord(self.join(), **options)
52 54
         return self._overlord
53 55
 
54 56
     def ready(self):
@@ -89,6 +91,9 @@ def _grammar(self):
89 91
                 threads=cly.Node(help='Get thread count')(
90 92
                     cly.Action(help='Get thread count', callback=self.get_threads),
91 93
                 ),
  94
+                timeout=cly.Node(help='Get timeout')(
  95
+                    cly.Action(help='Get timeout', callback=self.get_timeout),
  96
+                ),
92 97
             ),
93 98
             set=cly.Node(help='Define settings for the current session')(
94 99
                 async=cly.Node(help='Enable or disable async mode')(
@@ -115,6 +120,11 @@ def _grammar(self):
115 120
                         cly.Action(help='Set thread count', callback=self.set_threads),
116 121
                     ),
117 122
                 ),
  123
+                timeout=cly.Node(help='Set timeout')(
  124
+                    timeout=cly.Variable(pattern=r'([0-9]){1,}', help='Set client timeout')(
  125
+                        cly.Action(help='Set timeout', callback=self.set_timeout),
  126
+                    ),
  127
+                ),
118 128
             ),
119 129
         )
120 130
 
@@ -171,8 +181,20 @@ def set_clients(self, clients_set):
171 181
     def get_threads(self):
172 182
         print 'Thread count is %s.' % self.client.threads
173 183
 
  184
+    def get_timeout(self):
  185
+        if self.client.timeout is None:
  186
+            print 'Timeout is set to the func default.'
  187
+        else:
  188
+            print 'Timeout is %s seconds.' % self.client.timeout
  189
+
174 190
     def set_threads(self, thread_count):
175 191
         self.client.threads = int(thread_count)
176 192
 
  193
+    def set_timeout(self, timeout):
  194
+        timeout = int(timeout)
  195
+        if timeout <= 0:
  196
+            timeout = None
  197
+        self.client.timeout = timeout
  198
+
177 199
     def run(self):
178 200
         cly.interact(self.grammar, application='funcshell')

0 notes on commit d94fa39

Please sign in to comment.
Something went wrong with that request. Please try again.