PatienceConfig and Conductors

119 views
Skip to first unread message

kumar...@gmail.com

unread,
Dec 17, 2014, 3:43:03 PM12/17/14
to scalate...@googlegroups.com
Hi Folks, 

I am probably doing this wrong -I want the conductor to use a different timeout and for that...


          val conductor = new Conductor
          import conductor._
         
          implicit def patienceConfig: PatienceConfig  = PatienceConfig(Span(500, Millis), Span(50, Millis))
          
          for (n <- 1 until 10) {

            thread("broadcaster" + n) {
              val list = generateRandomList
               val bc = sc.broadcast(list)
               assert(bc.value.equals(list))
            }

          }
           whenFinished {

           }


I get timeout with default value:
RuntimeException was thrown during property evaluation.
[info]     Message: Test timed out because threads existed that were runnable while no progress was made (the beat did not advance) for 150 milliseconds.
[info]     Occurred when passed generated values (
[info]       arg0 = 2
[info]     )


What is the correct way to setup implicit defaults for patienceconfig to be used by conductors

Many thanks,
Amit


kumar...@gmail.com

unread,
Dec 18, 2014, 3:07:31 PM12/18/14
to scalate...@googlegroups.com
Just to answer my own question -I  was able to use custom timeout by directly calling conduct with implicit PatienceConfig. In the source code I see this comment

    // Won't write one that takes clockPeriod and timeout for 1.0. For now people
    // can just call conduct(a, b) directly followed by the code they want to run
    // afterwards. See if anyone asks for a whenFinished(a, b) {}
  

Thanks for scalatest.


Best,
Amit

Bill Venners

unread,
Dec 18, 2014, 5:12:17 PM12/18/14
to scalate...@googlegroups.com
Hi Amit,

Sorry I was busy yesterday when I approve your post, then forgot to go
back and answer it later. It looks like we may have received our first
"anyone asks for it."

At the time we wrote conductor originally, I think we were passing
configuration explicitly as an overloaded form of the conduct methods.
Now we could likely add an implicit without breaking client code,
other than it would pick up the patience in scope where before it did
not. It looks like, though, that your intuition was that it would do
just that. Do you think it would be better if the signature was:

def whenFinished(fun: => Unit)(implicit config: PatienceConfig): Unit = { ... }

Bill
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
> ---
> You received this message because you are subscribed to the Google Groups
> "scalatest-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scalatest-use...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com

Rodrigo Boavida

unread,
Mar 20, 2015, 12:11:44 PM3/20/15
to scalate...@googlegroups.com
Hi Amit and Bill,

I'm trying to make this work with my unit tests. Could you paste an example on how to use the conduct method with the custom timeout? I'm failing to find one.

Many thanks in advance,
Rod

Rodrigo Boavida

unread,
Mar 21, 2015, 4:05:57 AM3/21/15
to scalate...@googlegroups.com
Hi,

Just to answer my own question, seems we need to call the conduct() after the threads and before the  whenFinished, so something like this:
 
          for (n <- 1 until 10) {

            thread("broadcaster" + n) {
              val list = generateRandomList
               val bc = sc.broadcast(list)
               assert(bc.value.equals(list))
            }

          }
           implicit val patienceConfig = PatienceConfig(timeout = Span(50000, Millis), interval = Span(20, Millis))
           conduct()
           whenFinished {

           }

tnks,
Rod
Reply all
Reply to author
Forward
0 new messages