-
|
First of all, thank you for this versatile tool. In general, time tracking is a nuisance but Timewarrior makes it easy to automate and adapt to one's needs. Imagine an extension ("report") script that loops over today's Timewarrior intervals. It calls another system's API for each interval. On success it tags the corresponding Timewarrior interval by executing This means that the "timew report" process is still running while the extension spawns "timew tag …" processes repeatedly. Quoting the Extension API docs: "This is a one-way process, the extension has no way to communicate back to Timewarrior." -- I read this like "the communication protocol (stdin) implies that the extension cannot provide feedback other that its exit code". From the docs I cannot tell whether extensions may invoke timew. From the source code: in |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
|
If your first process is only reading, and doesn't rely on any of the read data being invariant while you write from the script (eg, by execve() or system()), then it should work. As long as there's only one writer at a time... |
Beta Was this translation helpful? Give feedback.
-
Adding tags to intervals is an idempotent operation, i.e adding a tag repeatedly to the same interval won't change the result. After the first
The message here is that the Because those calls are independent of each other, each operation is done on the then state of the database. Because modifying commands rely on the interval id to identify the interval to operate on, you have to be careful with any command in your script that changes the order of the intervals, i.e. their assigned ids. E.g., when |
Beta Was this translation helpful? Give feedback.
-
|
Thank you both @smemsh and @lauft for your replies. Let me try to summarize what I learned. Please correct me if I am wrong. On calling timew from an extension
That said, setting tags from the extension is not a problem because it does not change the intervals' IDs and it is even idempotent. My original concern was that the overarching "timew report" process would hold a lock on the database, so that "timew tag" invocations from the extension would fail or deadlock. It seems that this is not the case. On concurrency in generalAllow me to strain your patience with a rather academic question on concurrency: What if somebody ran multiple timew commands that change the database concurrently; for example from an extension that processes its input intervals in parallel threads. Rest assured, I am not going to do that, but it seems like a logical follow-up question. |
Beta Was this translation helpful? Give feedback.
-
it looks like db update is implemented by creating a new version in a temp file and |
Beta Was this translation helpful? Give feedback.
-
If you were going to do that, you would have to implement some external file locking mechanism, such that only one Timewarrior process manipulates the database at a time. Timewarrior itself does not provide that. |
Beta Was this translation helpful? Give feedback.
-
|
Once again, thank you both for your insights. I marked @lauft 's first reply as "the answer" but just because it was more detailed; re-reading @smemsh 's first reply I'd say it's also spot-on. So anyway, the whole thread is worth reading :-) |
Beta Was this translation helpful? Give feedback.
Adding tags to intervals is an idempotent operation, i.e adding a tag repeatedly to the same interval won't change the result. After the first
timew tag @4 FOOcall, interval@4has tagFOOadded. Repeating that same command won't change that, there will be only one tagFOOon the interval.The message here is that the
timewprocess calling your script will not react on the script's output/or its actions. It runs your extension with the re…