<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using Thread.sleep in Scala in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17426#M11450</link>
    <description>&lt;P&gt;Sounds like this is an instance of needing a synchronous blocking call, so a future wouldn't help the OP​&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jun 2022 20:33:35 GMT</pubDate>
    <dc:creator>ron_defreitas</dc:creator>
    <dc:date>2022-06-29T20:33:35Z</dc:date>
    <item>
      <title>Using Thread.sleep in Scala</title>
      <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17422#M11446</link>
      <description>&lt;P&gt;We need to hit REST web service every 5 mins until success message is received. The Scala object is inside a Jar file and gets invoked by Databricks task within a workflow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thread.sleep(5000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;is working fine but not sure if it is safe practice or is there any alternates.&lt;/P&gt;&lt;P&gt;Currently I have this implementation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while (true) {&lt;/P&gt;&lt;P&gt; // hit the rest web service&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(response == "success")&lt;/P&gt;&lt;P&gt;      return;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Thread.sleep(300000)&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 12:04:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17422#M11446</guid>
      <dc:creator>Sunny</dc:creator>
      <dc:date>2022-06-17T12:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using Thread.sleep in Scala</title>
      <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17423#M11447</link>
      <description>&lt;P&gt;Nothing wrong with using Sleep per se, but this business logic lacks timeout logic.&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;If it never returns success, your job will run forever, consuming DBUs as well as cloud compute costs.&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;Using​ the scala concurrent duration classes,  you can create a deadline, then write your code to incorporate that.&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;P&gt;while (deadline.hasTimeLeft()) {&lt;/P&gt;&lt;P&gt;  // your break logic&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  // sleep&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 19:24:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17423#M11447</guid>
      <dc:creator>ron_defreitas</dc:creator>
      <dc:date>2022-06-29T19:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using Thread.sleep in Scala</title>
      <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17424#M11448</link>
      <description>&lt;P&gt;I'll add that you may wish to hit the endpoint more frequently if your web service can take it... ​it's wasteful to poll once every five minutes for a response that might return at 5 minutes and 1 second.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 19:26:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17424#M11448</guid>
      <dc:creator>ron_defreitas</dc:creator>
      <dc:date>2022-06-29T19:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Thread.sleep in Scala</title>
      <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17425#M11449</link>
      <description>&lt;P&gt;Have you tried using Scala Futures? &lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 20:09:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17425#M11449</guid>
      <dc:creator>angrypanda</dc:creator>
      <dc:date>2022-06-29T20:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using Thread.sleep in Scala</title>
      <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17426#M11450</link>
      <description>&lt;P&gt;Sounds like this is an instance of needing a synchronous blocking call, so a future wouldn't help the OP​&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 20:33:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17426#M11450</guid>
      <dc:creator>ron_defreitas</dc:creator>
      <dc:date>2022-06-29T20:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using Thread.sleep in Scala</title>
      <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17427#M11451</link>
      <description>&lt;P&gt;Thank you. For ex, if the job has a timeout set to 15 mins and the code has while(true), after 15 mins isn't the job killed automatically?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 12:06:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17427#M11451</guid>
      <dc:creator>Sunny</dc:creator>
      <dc:date>2022-06-30T12:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using Thread.sleep in Scala</title>
      <link>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17428#M11452</link>
      <description>&lt;P&gt;Hey there @Sundeep P​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 16:18:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/using-thread-sleep-in-scala/m-p/17428#M11452</guid>
      <dc:creator>Vartika</dc:creator>
      <dc:date>2022-08-24T16:18:18Z</dc:date>
    </item>
  </channel>
</rss>

