473,700 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I need to stop the get method process its take more than 60 sec.

8 New Member
Hi All,

I used LWP::USerAgent module to get the data from the URL. If the URL get slow or some other reason to take the data more than 60 seconds need to exit from the method.

Is there any way to quit the method while get method processing more than 60 seconds.

Regards,
Ram.

I used the below code to get the data's from URL.

Expand|Select|Wrap|Line Numbers
  1. use warnings;
  2.     use strict;
  3.     use LWP::UserAgent;
  4.     use HTTP::Request;
  5.     use HTTP::Cookies;
  6.         my $inurl = "http://www.tcsonline.co.uk/Vessel_Schedule.asp";
  7.  
  8.     my $ua=LWP::UserAgent->new;
  9.     $ua->agent("User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:8.0.1) Gecko/20100101 Firefox/8.0.1");
  10.  
  11.     my $cookie= HTTP::Cookies->new(file=>"$0.txt",autosave => 1,);
  12.     $ua->cookie_jar($cookie);
  13.     $ua->timeout(0);
  14.     my $req=HTTP::Request->new(GET=>"$inurl");
  15.     $req->header("User-Agent" => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 ( .NET4.0E)");
  16.     $req->header("Content-Type" => "text/html");
  17.  
  18.     my $res=$ua->request($req);
  19.     $cookie->extract_cookies($res);
  20.     $cookie->save;
  21.     $cookie->add_cookie_header($req);
  22.     my $code=$res->code;
  23.     my $page_content;
  24.     if($code=~m/20/is)
  25.     {        
  26.     $page_content=$res->content();
  27.  
  28.     }
  29.     open OUToutfile, ">Vessel.txt";
  30.     print OUToutfile $page_content;
  31.     close OUToutfile;
Jun 25 '12 #1
1 1986
numberwhun
3,509 Recognized Expert Moderator Specialist
Please be sure and always read the documentation for the modules you are using. If you check that link, you will see there is a timeout for the constructor method.

Regards,

Jeff
Jun 25 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2716
by: Tom | last post by:
A Java applet has two methods stop() and destroy() that get called when the user moves to a different page. Does javascript have anything similar? thanks tom
0
1286
by: strangedub | last post by:
I am working on a C# Windows program that needs to kill a known process. I have written code that works in development mode but hits an "Access Denied" exception when running the compiled program: Here's my original code: // Now stop the server process Process myProcesses; myProcesses = Process.GetProcessesByName("MyServer"); foreach(Process myProcess in myProcesses) {
3
15449
by: Sunny | last post by:
Hi All I am creating a C# app, in which there are some methods that are considerably longer than the others and take a few minutes to complete, I want to give the users an option to stop that method (which is in process). I want to include a command button using which the user of the app, can stop that process. Another thing that i want to add is that, while stopping the mthod execution, i do not want the Windows Form to close, only the in...
2
1574
by: Chan | last post by:
If i call invalidate() two times, how can I stop the process for some time between them? that is, do updating ----> invalidate() -->do updating----> pause--> invalidate() I update my data in my program 2 times , i want to see what is the change of the srceen in these 2 update , but i found the srceen change too fast so i can't see what is the change of the first update , do there exist any class that can stop the process for while?
14
2078
by: Harry Keck | last post by:
I have client side code that uses xmlhttp to make an asyncronous call to the server. This call really churns the server and can take a couple of minutes to finish. I have found that while this long call is processing, I can not make any more requests to the server from the same session. I found this because if I have two completely separate instances of IE, they will not block each other, but if I do a File/New to spawn a separate...
1
1820
friendjin
by: friendjin | last post by:
Thanks in advance; Can I ask a question about VC++.NET 2003. about using window form application. when I click button1, the programming will be run, and the results will be displayed in textbox1, we are able to see update values in textbox1, to achieve this function, I used the while loop to loop forever. you know the problem is it could not be stopped. So I want to create a stop button, once I click this button, it should be stopped...
3
1357
by: ebcouv | last post by:
I need to stop a process that is started by an add-in for Excel. I want to do this with VB code (without having to open Taskmaster). Can someone please show me the code to do this???? THANKS...
3
1836
by: shimajavar | last post by:
Hi all I have the following code: a line is growing up by clicking on "up" button, it has another button"start" which I want it to stop the process of growing the line...How can I make a button to stop the process of another button? class Program: Form { int x1; int y1; int x2;
0
1690
by: Benjamins via AccessMonster.com | last post by:
The microsoft jet database engine stop the process because you and another user are attempting to change the same data. The system produce this error message when i run a certain form. It will appear only sometime. What has cause this error as this data is only used by one user and the user did not access the data by other means other than the system that is accessing the data. -- Message posted via AccessMonster.com
4
7138
by: Jonathan | last post by:
I have a SQL stored procedure for adding a new record in a transactions table. It also has two return values: CounterID and IDKey. I want to create a webservice that accepts the 10 input parameters and returns the two return values. My C# programmer here says that webservice methods can only return 1 value per method. Is that right? Though I haven't ever created a webservice, I would have thought that a method could return a whole lot...
0
8714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9060
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2379
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2021
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.