sarge.command_line_parser not thread safe

Issue #13 resolved
Former user created an issue

This in turn makes calling sarge.run() not thread safe as well and running this in separate threads eventually will cause corrupted command lines or plain brokeness, as expected.

Adjusting Pipeline.__init__() to create a new CommandLineParser instance each time seems to fix the immediate safety issue caused by reusing the same parser instance.

diff -r 621cf40a6457 sarge/__init__.py
--- a/sarge/__init__.py Sun Aug 11 13:22:08 2013 +0100
+++ b/sarge/__init__.py Sun Aug 11 22:30:06 2013 +0000
@@ -929,7 +929,7 @@
             t = Node(kind='command', command=source, redirects={})
         else:
             self.source = source
-            t = command_line_parser.parse(source, posix=posix)
+            t = CommandLineParser().parse(source, posix=posix)
         self.tree = t
         self.last = self.find_last_command(t)
         self.events = []

Comments (1)

  1. Log in to comment