Clojure

GC Issue 26: agent error queue

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.2
  • Component/s: None
  • Labels:
    None
  • Approval:
    Ok

Description

Reported by richhickey, Jan 01, 2009
Route agent errors to a queue

Comment 1 by chouser, May 26, 2009
The attached patch allows agents to have an error-callback, which could be used to
route errors to one or more queues.

Example usage:

user=> (send-off (agent nil
                   :error-callback (fn [a es]
                                     (.printStackTrace (first es))
                                     (clear-agent-errors a)))
                 (fn f [_]
                   (Thread/sleep 1000)
                   (send-off *agent* f)))
#<Agent@5dd2b9b7: nil>
user=> (shutdown-agents)
nil
user=>
java.lang.RuntimeException: Error executing action user$eval__394$f__399@63d87b85
        at clojure.lang.Agent$Action.execute(Agent.java:63)
        at clojure.lang.Agent$Action.doRun(Agent.java:107)
        at clojure.lang.Agent$Action.run(Agent.java:118)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.util.concurrent.RejectedExecutionException
        at
java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1760)
        at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
        at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)
        at clojure.lang.Agent$Action.execute(Agent.java:57)
        ... 5 more

 error-callback.patch
3.9 KB Download

Activity

Hide
Assembla Importer added a comment -

cemerick said: [file:dY6WBiw3er3R14eJe5aVNr]

Show
Assembla Importer added a comment - cemerick said: [file:dY6WBiw3er3R14eJe5aVNr]
Hide
Assembla Importer added a comment -

richhickey said: Updating tickets (#8, #19, #30, #31, #126, #17, #42, #47, #50, #61, #64, #69, #71, #77, #79, #84, #87, #89, #96, #99, #103, #107, #112, #113, #114, #115, #118, #119, #121, #122, #124)

Show
Assembla Importer added a comment - richhickey said: Updating tickets (#8, #19, #30, #31, #126, #17, #42, #47, #50, #61, #64, #69, #71, #77, #79, #84, #87, #89, #96, #99, #103, #107, #112, #113, #114, #115, #118, #119, #121, #122, #124)
Hide
Assembla Importer added a comment -

richhickey said: could you please name them set/get-agent-error-callback and mark them as experimental? thanks

Show
Assembla Importer added a comment - richhickey said: could you please name them set/get-agent-error-callback and mark them as experimental? thanks
Hide
Assembla Importer added a comment -

richhickey said: <pre>could you please name them set/get-agent-error-callback and mark them as experimental? thanks></pre>

Show
Assembla Importer added a comment - richhickey said: <pre>could you please name them set/get-agent-error-callback and mark them as experimental? thanks></pre>
Hide
Assembla Importer added a comment -

richhickey said: could you please name them set/get-agent-error-callback and mark them as experimental? thanks

Show
Assembla Importer added a comment - richhickey said: could you please name them set/get-agent-error-callback and mark them as experimental? thanks
Hide
Assembla Importer added a comment -

chouser@n01se.net said: <pre>I was under the impression this patch had some significant
flaws:

http://clojure-log.n01se.net/date/2009-05-26.html#11:22-11:50

Specific issues:

  • error handlers using clear-agent-errors
  • the error being a seq instead of a single error
  • no way for the handler to know what the action or action
    args were (needed to re-run the action)

Is marking this as "experimental" sufficient to cover those
issues for now?</pre>

Show
Assembla Importer added a comment - chouser@n01se.net said: <pre>I was under the impression this patch had some significant flaws: http://clojure-log.n01se.net/date/2009-05-26.html#11:22-11:50 Specific issues:
  • error handlers using clear-agent-errors
  • the error being a seq instead of a single error
  • no way for the handler to know what the action or action args were (needed to re-run the action)
Is marking this as "experimental" sufficient to cover those issues for now?</pre>
Hide
Assembla Importer added a comment -

richhickey said: <pre>
I agree this still needs work, but would be nice to get it in people's hands
to get some feedback.

I guess don't mark it fixed until we are happy with it? Or, we could create a branch
</pre>

Show
Assembla Importer added a comment - richhickey said: <pre> I agree this still needs work, but would be nice to get it in people's hands to get some feedback. I guess don't mark it fixed until we are happy with it? Or, we could create a branch </pre>
Hide
Assembla Importer added a comment -

richhickey said: We need to finesse this a bit or pull for 1.1. I'm not sure anyone is using it, so we've had no feedback. I don't want to marry the error seq, so how about just simply:

agent + exception
clear-agent-errors is not ok in a handler
mark as experimental - subject to change

Show
Assembla Importer added a comment - richhickey said: We need to finesse this a bit or pull for 1.1. I'm not sure anyone is using it, so we've had no feedback. I don't want to marry the error seq, so how about just simply: agent + exception clear-agent-errors is not ok in a handler mark as experimental - subject to change
Hide
Assembla Importer added a comment -

chouser@n01se.net said: A proposed solution is discussed here:

http://www.assembla.com/wiki/show/clojure/Agent_exception_handlers

Show
Assembla Importer added a comment - chouser@n01se.net said: A proposed solution is discussed here: http://www.assembla.com/wiki/show/clojure/Agent_exception_handlers
Hide
Assembla Importer added a comment -

chouser@n01se.net said: [file:cwEwcA_RSr3RpIeJe5aVNr]: Implementation of :error-handler proposal – still needs docstrings and more testing, but code should be complete.

Show
Assembla Importer added a comment - chouser@n01se.net said: [file:cwEwcA_RSr3RpIeJe5aVNr]: Implementation of :error-handler proposal – still needs docstrings and more testing, but code should be complete.
Hide
Assembla Importer added a comment -

chouser@n01se.net said: (In [[r:b63af1ad6ce38b50552be3c424ea166cb063ee7c]]) Add agent error handlers and error modes :fail and :continue. Fixes #30

Branch: master

Show
Assembla Importer added a comment - chouser@n01se.net said: (In [[r:b63af1ad6ce38b50552be3c424ea166cb063ee7c]]) Add agent error handlers and error modes :fail and :continue. Fixes #30 Branch: master

People

  • Assignee:
    Chouser
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: