Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add env-var to record shell init time #833

Closed
nerdvegas opened this issue Jan 10, 2020 · 3 comments · Fixed by #834
Closed

add env-var to record shell init time #833

nerdvegas opened this issue Jan 10, 2020 · 3 comments · Fixed by #834

Comments

@nerdvegas
Copy link
Contributor

nerdvegas commented Jan 10, 2020

I have a case where I need to know the time when a tool was launched, which is done via ResolvedContext.execute_shell (eg, when you run rez-env blah -- mycommand). I would like to write this to an env-var.

The existing REZ_USED_TIMESTAMP (https://github.com/nerdvegas/rez/wiki/Environment-Variables#context-environment-variables) is similar to what I need, but not quite right. REZ_USED_TIMESTAMP is set to --timestamp if present, rather than the true time of resolve. Furthermore, it's time the context was resolved, not the time that a command was run, which can occur later (a context can be resolved once and used many times after - eg, suites).

I propose adding a new REZ_SHELL_INIT_TIMESTAMP env-var, which is set to epoch time every time a shell is created (via execute_shell).

Related - it would also be useful to set a var that indicates whether a command was run or not (ie command arg in execute_shell). The reason - I need to determine tool startup time, and if command is None, this generally means that an interactive shell was started, and I need to filter out those cases.

@instinct-vfx
Copy link
Contributor

Seems like a useful addition to me! I am a bit unsure about setting it to --timestamp if present. That seems a bit odd to return a different value depending on the parameters. As a user i would rather expect that SHELL_INIT_TIMESTAMP always reflects the shell init time and not an arbitrarily set value.

When working with the value you could check if REZ_USED_REQUESTED_TIMESTAMP is non-zero and use that or else use REZ_SHELL_INIT_TIMESTAMP rather than have REZ_SHELL_INIT_TIMESTAMP reflect two different meanings.

Thoughts?

@nerdvegas
Copy link
Contributor Author

Ah, the ticket reads a little ambiguously. I meant that REZ_USED_TIMESTAMP respects --timestamp, not that REZ_SHELL_INIT_TIMESTAMP should.

@instinct-vfx
Copy link
Contributor

Ah, sorry, i misread that. That makes sense and i take back everything i said ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants