Skip to content

Commit

Permalink
Bug 1860671 - Use subprocess instead of mozprocess in mozlint r=hneiva
Browse files Browse the repository at this point in the history
Reduce reliance on mozprocess ProcessHandler, which is poorly maintained.

Differential Revision: https://phabricator.services.mozilla.com/D191695
  • Loading branch information
gbrownmozilla committed Oct 26, 2023
1 parent 8ec3d36 commit 82ac3c8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions python/mozlint/mozlint/util/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import signal
import subprocess
from abc import ABC, abstractmethod

from mozprocess import ProcessHandlerMixin


class LintProcess(ProcessHandlerMixin, ABC):
class LintProcess(subprocess.Popen, ABC):
def __init__(self, config, *args, **kwargs):
self.config = config
self.results = []

kwargs["universal_newlines"] = True
kwargs["processOutputLine"] = [self.process_line]
ProcessHandlerMixin.__init__(self, *args, **kwargs)
kwargs["text"] = True
kwargs["stdout"] = subprocess.PIPE
kwargs["stderr"] = subprocess.STDOUT
orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
subprocess.Popen.__init__(self, *args, **kwargs)
signal.signal(signal.SIGINT, orig)

@abstractmethod
def process_line(self, line):
Expand All @@ -29,7 +31,6 @@ def process_line(self, line):
"""
pass

def run(self, *args, **kwargs):
orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
ProcessHandlerMixin.run(self, *args, **kwargs)
signal.signal(signal.SIGINT, orig)
def run(self):
for line in self.stdout:
self.process_line(line)

0 comments on commit 82ac3c8

Please sign in to comment.