zsh-workers
 help / color / mirror / code / Atom feed
* fc -ap -R stalls when called from sched
@ 2016-09-11  8:58 Sebastian Gniazdowski
  2016-09-11  9:01 ` Sebastian Gniazdowski
  2016-09-12  0:17 ` Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-11  8:58 UTC (permalink / raw)
  To: Zsh hackers list

Hello,
I call function __convey_on_period_passed() from sched +1 mechanism.
There, I read an IO file (file used for data conveying). I use the
neat trick that worked for me in past, but not now:

    # Read input using history mechanism
    local -a commands
    () { fc -ap -R "$datafile"; commands=( ${history[@]} ) }

Shell stalls for ~10 seconds, then continues with data correctly read.
Whole source with debug marks is here:

https://github.com/psprint/zconvey/blob/001a5378177dcfdd0de388e19f5c7ca067c0a89c/zconvey.plugin.zsh#L174-L183

Asciinema showing the effect:

https://asciinema.org/a/9mfxg2j1jcwvoo7tb5x6bagr4

Removing anonymous function doesn't help. Doing normal load via
commands=( "${(@f)"$(<$datafile)"}" ) does help.


The plugin is for: a) assigning IDs and names to Zsh sessions b) doing
"zconvey -n Devel vim ~/.zshrc" to fire up command on Zsh session
named "Devel" (not implemented yet, thus a manual print -rl -- is used
to fill IO file).

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fc -ap -R stalls when called from sched
  2016-09-11  8:58 fc -ap -R stalls when called from sched Sebastian Gniazdowski
@ 2016-09-11  9:01 ` Sebastian Gniazdowski
  2016-09-11  9:14   ` Sebastian Gniazdowski
  2016-09-12  0:17 ` Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-11  9:01 UTC (permalink / raw)
  To: Zsh hackers list

PS. Thought that I could provide a minimum test case. However, following:

myfunction() { local -a arr; fc -ap -R ~/.zshrc; arr=( ${history[@]}
); print -rl -- "Read:" "${(@)arr[1,3]}"; }
sched +1 myfunction

works fine...


On 11 September 2016 at 10:58, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> Hello,
> I call function __convey_on_period_passed() from sched +1 mechanism.
> There, I read an IO file (file used for data conveying). I use the
> neat trick that worked for me in past, but not now:
>
>     # Read input using history mechanism
>     local -a commands
>     () { fc -ap -R "$datafile"; commands=( ${history[@]} ) }
>
> Shell stalls for ~10 seconds, then continues with data correctly read.
> Whole source with debug marks is here:
>
> https://github.com/psprint/zconvey/blob/001a5378177dcfdd0de388e19f5c7ca067c0a89c/zconvey.plugin.zsh#L174-L183
>
> Asciinema showing the effect:
>
> https://asciinema.org/a/9mfxg2j1jcwvoo7tb5x6bagr4
>
> Removing anonymous function doesn't help. Doing normal load via
> commands=( "${(@f)"$(<$datafile)"}" ) does help.
>
>
> The plugin is for: a) assigning IDs and names to Zsh sessions b) doing
> "zconvey -n Devel vim ~/.zshrc" to fire up command on Zsh session
> named "Devel" (not implemented yet, thus a manual print -rl -- is used
> to fill IO file).
>
> Best regards,
> Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fc -ap -R stalls when called from sched
  2016-09-11  9:01 ` Sebastian Gniazdowski
@ 2016-09-11  9:14   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-11  9:14 UTC (permalink / raw)
  To: Zsh hackers list

PS. The commit with debug marks etc. is: 001a537

Best regards,
Sebastian Gniazdowski


On 11 September 2016 at 11:01, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> PS. Thought that I could provide a minimum test case. However, following:
>
> myfunction() { local -a arr; fc -ap -R ~/.zshrc; arr=( ${history[@]}
> ); print -rl -- "Read:" "${(@)arr[1,3]}"; }
> sched +1 myfunction
>
> works fine...
>
>
> On 11 September 2016 at 10:58, Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
>> Hello,
>> I call function __convey_on_period_passed() from sched +1 mechanism.
>> There, I read an IO file (file used for data conveying). I use the
>> neat trick that worked for me in past, but not now:
>>
>>     # Read input using history mechanism
>>     local -a commands
>>     () { fc -ap -R "$datafile"; commands=( ${history[@]} ) }
>>
>> Shell stalls for ~10 seconds, then continues with data correctly read.
>> Whole source with debug marks is here:
>>
>> https://github.com/psprint/zconvey/blob/001a5378177dcfdd0de388e19f5c7ca067c0a89c/zconvey.plugin.zsh#L174-L183
>>
>> Asciinema showing the effect:
>>
>> https://asciinema.org/a/9mfxg2j1jcwvoo7tb5x6bagr4
>>
>> Removing anonymous function doesn't help. Doing normal load via
>> commands=( "${(@f)"$(<$datafile)"}" ) does help.
>>
>>
>> The plugin is for: a) assigning IDs and names to Zsh sessions b) doing
>> "zconvey -n Devel vim ~/.zshrc" to fire up command on Zsh session
>> named "Devel" (not implemented yet, thus a manual print -rl -- is used
>> to fill IO file).
>>
>> Best regards,
>> Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: fc -ap -R stalls when called from sched
  2016-09-11  8:58 fc -ap -R stalls when called from sched Sebastian Gniazdowski
  2016-09-11  9:01 ` Sebastian Gniazdowski
@ 2016-09-12  0:17 ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2016-09-12  0:17 UTC (permalink / raw)
  To: Zsh hackers list

On Sep 11, 10:58am, Sebastian Gniazdowski wrote:
}
} I call function __convey_on_period_passed() from sched +1 mechanism.
} 
}     # Read input using history mechanism
}     local -a commands
}     () { fc -ap -R "$datafile"; commands=( ${history[@]} ) }
} 
} Shell stalls for ~10 seconds, then continues with data correctly read.

The most likely thing going on is that lockhistfile() is spinning on
repeated attempts to have exclusive access to the file.

} Removing anonymous function doesn't help. Doing normal load via
} commands=( "${(@f)"$(<$datafile)"}" ) does help.

Since opening for read with redirection doesn't attempt to lock, this
would make sense in relation to the previous hypothesis.

} The plugin is for: a) assigning IDs and names to Zsh sessions b) doing
} "zconvey -n Devel vim ~/.zshrc" to fire up command on Zsh session
} named "Devel" (not implemented yet, thus a manual print -rl -- is used
} to fill IO file).

If you're going to read the file with "fc -R" why not write it also with
"fc -W" or "fc -A"?  Then the history mechanism would handle all of your
locking and you wouldn't need "zsystem flock" or its workaround.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-12  0:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-11  8:58 fc -ap -R stalls when called from sched Sebastian Gniazdowski
2016-09-11  9:01 ` Sebastian Gniazdowski
2016-09-11  9:14   ` Sebastian Gniazdowski
2016-09-12  0:17 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).