Skip to content

Commit

Permalink
deprecating with contexts. closes #195
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Moffat committed Dec 30, 2014
1 parent 5b3a99c commit 5f461dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.10 -

* deprecated `_with` contexts [#195](https://github.com/amoffat/sh/issues/195)
* `_timeout_signal` allows you to specify your own signal to kill a timed-out process with. use a constant from the `signal` stdlib module. [#171](https://github.com/amoffat/sh/issues/171)
* signal exceptions can now be caught by number or name. `SignalException_9 == SignalException_SIGKILL`
* child processes that timeout via `_timeout` raise `sh.TimeoutException` instead of `sh.SignalExeception_9` [#172](https://github.com/amoffat/sh/issues/172)
Expand Down
12 changes: 11 additions & 1 deletion sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ def callable(ob):
import weakref


# TODO remove with contexts in next version
def with_context_warning():
warnings.warn("""
with contexts are deprecated because they are not thread safe. they will be \
removed in the next version. use subcommands instead \
http://amoffat.github.io/sh/#sub-commands. see \
https://github.com/amoffat/sh/issues/195
""".strip(), stacklevel=3)



if IS_PY3:
Expand Down Expand Up @@ -536,7 +545,7 @@ def __enter__(self):
been done would have been done in the Command.__call__ call.
essentially all that has to happen is the comand be pushed on the
prepend stack. """
pass
with_context_warning()

def __iter__(self):
return self
Expand Down Expand Up @@ -930,6 +939,7 @@ def __unicode__(self):
return self._path.decode(DEFAULT_ENCODING) + baked_args

def __enter__(self):
with_context_warning()
self(_with=True)

def __exit__(self, typ, value, traceback):
Expand Down

0 comments on commit 5f461dd

Please sign in to comment.