tools: wasptool: Introduce simple chunking
This reduces the memory overhead required to --exec a file (although we will still have problems with big classes). For now we have avoided matching "^def" since we need additional handling for decorators!
This commit is contained in:
parent
fe43091bcf
commit
1fe0602995
1 changed files with 19 additions and 4 deletions
|
@ -46,7 +46,7 @@ def unsync(c):
|
||||||
c.expect('Watch is running, use Ctrl-C to stop')
|
c.expect('Watch is running, use Ctrl-C to stop')
|
||||||
c.send('\x18')
|
c.send('\x18')
|
||||||
|
|
||||||
def paste(c, f, verbose=False):
|
def paste(c, f, verbose=False, chunk=None):
|
||||||
docstring = False
|
docstring = False
|
||||||
|
|
||||||
tosend = []
|
tosend = []
|
||||||
|
@ -66,9 +66,15 @@ def paste(c, f, verbose=False):
|
||||||
if ln.lstrip().startswith('#'):
|
if ln.lstrip().startswith('#'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if ln.strip() == '':
|
||||||
|
continue
|
||||||
|
|
||||||
tosend.append(ln)
|
tosend.append(ln)
|
||||||
|
|
||||||
for ln in pbar(tosend, verbose):
|
for ln in pbar(tosend, verbose):
|
||||||
|
if chunk and ln.startswith('class'):
|
||||||
|
chunk()
|
||||||
|
|
||||||
c.sendline(ln)
|
c.sendline(ln)
|
||||||
c.expect('=== ')
|
c.expect('=== ')
|
||||||
|
|
||||||
|
@ -89,6 +95,15 @@ def handle_eval(c, cmd):
|
||||||
def handle_exec(c, fname):
|
def handle_exec(c, fname):
|
||||||
verbose = bool(c.logfile)
|
verbose = bool(c.logfile)
|
||||||
|
|
||||||
|
def chunk():
|
||||||
|
c.logfile = sys.stdout
|
||||||
|
c.send('\x04')
|
||||||
|
c.expect('>>> ')
|
||||||
|
if not verbose:
|
||||||
|
c.logfile = None
|
||||||
|
c.send('\x05')
|
||||||
|
c.expect('=== ')
|
||||||
|
|
||||||
with open(fname) as f:
|
with open(fname) as f:
|
||||||
if not verbose:
|
if not verbose:
|
||||||
print(f'Preparing to run {fname}:')
|
print(f'Preparing to run {fname}:')
|
||||||
|
@ -96,7 +111,7 @@ def handle_exec(c, fname):
|
||||||
c.send('\x05')
|
c.send('\x05')
|
||||||
c.expect('=== ')
|
c.expect('=== ')
|
||||||
|
|
||||||
paste(c, f, verbose)
|
paste(c, f, verbose, chunk)
|
||||||
|
|
||||||
c.logfile = sys.stdout
|
c.logfile = sys.stdout
|
||||||
c.send('\x04')
|
c.send('\x04')
|
||||||
|
|
Loading…
Add table
Reference in a new issue