Skip to content

Commit

Permalink
Examine sub-bundles when detecting changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
toolness committed Feb 1, 2019
1 parent 71a08c1 commit 0c2c4a9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion project/util/lambda_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import subprocess
import json
import glob
from dataclasses import dataclass
from typing import List, Any, BinaryIO, Optional
from threading import RLock
Expand Down Expand Up @@ -92,7 +93,7 @@ def __get_process(self) -> subprocess.Popen:

with self.__lock:
if self.restart_on_script_change:
mtime = self.script_path.stat().st_mtime
mtime = get_latest_mtime_for_bundle(self.script_path)
if mtime != self.__script_path_mtime:
self.__script_path_mtime = mtime
logger.debug(
Expand Down Expand Up @@ -186,6 +187,20 @@ def run_handler(self,
)


def get_latest_mtime_for_bundle(path: Path) -> float:
'''
Get the most recent modified time for the given source
bundle and any of its loadable sub-bundles. It is assumed
the sub-bundles all end with the name of the original source
bundle, e.g. if the source bundle is called "foo.js",
a source bundle would be "bar.foo.js".
'''

filenames = [str(path)] + glob.glob(str(path.with_name(f"*.{path.name}")))
latest_mtime = max(Path(filename).stat().st_mtime for filename in filenames)
return latest_mtime


class MalformedResponseError(Exception):
'''
This error is raised if a lambda process' response is not valid
Expand Down

0 comments on commit 0c2c4a9

Please sign in to comment.