<?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: time.sleep not working in modular input ? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179241#M35940</link>
    <description>&lt;P&gt;If I run without the time.sleep, everything goes fine, i get a lot of answers...&lt;BR /&gt;
If I run with, I have no errors in the splunk.d logs, and nothing being indexed...&lt;/P&gt;</description>
    <pubDate>Sat, 14 Dec 2013 20:14:39 GMT</pubDate>
    <dc:creator>sbsbb</dc:creator>
    <dc:date>2013-12-14T20:14:39Z</dc:date>
    <item>
      <title>time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179239#M35938</link>
      <description>&lt;P&gt;I modified the helloworld in the python modular input example, to poll a website, and calculate the latency. &lt;/P&gt;

&lt;P&gt;I don't understand why it is not working when I add a time.sleep, without, it is workint !!?&lt;/P&gt;

&lt;P&gt;def do_run():&lt;BR /&gt;
    config = get_input_config()&lt;BR /&gt;&lt;BR /&gt;
    #TODO , poll for data and print output to STD OUT&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;while True :
    try:
        interval=float(config['interval'])
        #time.sleep(interval)
        start_timer = time.time()
        resp = urllib2.urlopen(config['url'])
        content = resp.read()
        latency = time.time() - start_timer
        print_xml_single_instance_mode( "time=" + str(start_timer)  + " latency=" + str(round(latency,2)) + " interval=" + str(interval) )
        assert (resp.code == 200), 'Bad HTTP Response'
        #assert ('Example Web Page' in content), 'Failed Content Verification'

    except RuntimeError,e:
        logging.error("Looks like an error: %s" % str(e))
        sys.exit(2) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:29:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179239#M35938</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2020-09-28T15:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179240#M35939</link>
      <description>&lt;P&gt;I'm doing exactly the same in several modular inputs. It should work with no issue. Can you describe more precisely what happens when you run it?&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
Simon&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2013 17:08:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179240#M35939</guid>
      <dc:creator>Simon</dc:creator>
      <dc:date>2013-12-14T17:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179241#M35940</link>
      <description>&lt;P&gt;If I run without the time.sleep, everything goes fine, i get a lot of answers...&lt;BR /&gt;
If I run with, I have no errors in the splunk.d logs, and nothing being indexed...&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2013 20:14:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179241#M35940</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-14T20:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179242#M35941</link>
      <description>&lt;P&gt;Did you try to run the script by hand? For example like:&lt;BR /&gt;
$SPLUNK_HOME/bin/splunk cmd splunkd print-modinput-config yourmodinputname | $SPLUNK_HOME/bin/splunk cmd python $SPLUNK_HOME/etc/apps/yourappname/bin/yourmodinputname.py&lt;/P&gt;

&lt;P&gt;This always helped me to debug the modular inputs since it's the way how splunk will launch them.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:29:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179242#M35941</guid>
      <dc:creator>Simon</dc:creator>
      <dc:date>2020-09-28T15:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179243#M35942</link>
      <description>&lt;P&gt;I tried on windows, put I only see a black new terminal, without anyting... no output, is there something I have to set to verbose ?&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2013 20:17:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179243#M35942</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-15T20:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179244#M35943</link>
      <description>&lt;P&gt;Actually you should see what your method print_xml_single_instance_mode() prints to stdout, which should get indexed later. If you like to, you can send me over your script and I'll try to debug it...&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:29:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179244#M35943</guid>
      <dc:creator>Simon</dc:creator>
      <dc:date>2020-09-28T15:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179245#M35944</link>
      <description>&lt;P&gt;Hi in fact the only change in the script is here, when I uncomment #time.sleep... it doesn't work, it is commented, then it works. &lt;BR /&gt;
The rest ist the normal helloword from the python sdk modular input&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEBB"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEBB&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 09:48:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179245#M35944</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-16T09:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179246#M35945</link>
      <description>&lt;P&gt;Try adding a &lt;STRONG&gt;sys.stdout.flush()&lt;/STRONG&gt;  after the &lt;STRONG&gt;print_xml_single_instance_mode&lt;/STRONG&gt; line.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:29:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179246#M35945</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2020-09-28T15:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179247#M35946</link>
      <description>&lt;P&gt;could you explain me why this is needed ?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 12:33:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179247#M35946</guid>
      <dc:creator>sbsbb</dc:creator>
      <dc:date>2013-12-16T12:33:54Z</dc:date>
    </item>
    <item>
      <title>Re: time.sleep not working in modular input ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179248#M35947</link>
      <description>&lt;P&gt;It's because sys.stdout is buffered. In a sleep loop you need to explicitly flush the buffer.With the sleep the script exits and flushes the buffer for you.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2013 12:50:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/time-sleep-not-working-in-modular-input/m-p/179248#M35947</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-12-16T12:50:24Z</dc:date>
    </item>
  </channel>
</rss>

